mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-02-25 08:05:04 +08:00
new grid X offset calcs to fix some issues
also fixed a save_restore issue with grid alignments now save_restoreGB() saves/restores offset values added macro enumeration of SAVE vs RESTORE for save_restore commands.
This commit is contained in:
parent
999d57c201
commit
3fd7fce4ac
8 changed files with 51 additions and 67 deletions
|
@ -71,7 +71,7 @@ void save_restoreDB(uint8_t saveOpt)
|
|||
static int savedDemodStartIdx = 0;
|
||||
static int savedDemodClock = 0;
|
||||
|
||||
if (saveOpt==1) { //save
|
||||
if (saveOpt == GRAPH_SAVE) { //save
|
||||
|
||||
memcpy(SavedDB, DemodBuffer, sizeof(DemodBuffer));
|
||||
SavedDBlen = DemodBufferLen;
|
||||
|
|
|
@ -879,25 +879,25 @@ int CheckChipType(char cmdp) {
|
|||
|
||||
if (offline || cmdp == '1') return 0;
|
||||
|
||||
save_restoreGB(1);
|
||||
save_restoreDB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
save_restoreDB(GRAPH_SAVE);
|
||||
//check for em4x05/em4x69 chips first
|
||||
if (EM4x05Block0Test(&wordData)) {
|
||||
PrintAndLog("\nValid EM4x05/EM4x69 Chip Found\nTry lf em 4x05... commands\n");
|
||||
save_restoreGB(0);
|
||||
save_restoreDB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
save_restoreDB(GRAPH_RESTORE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//check for t55xx chip...
|
||||
if (tryDetectP1(true)) {
|
||||
PrintAndLog("\nValid T55xx Chip Found\nTry lf t55xx ... commands\n");
|
||||
save_restoreGB(0);
|
||||
save_restoreDB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
save_restoreDB(GRAPH_RESTORE);
|
||||
return 1;
|
||||
}
|
||||
save_restoreGB(0);
|
||||
save_restoreDB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
save_restoreDB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ int CmdLFfind(const char *Cmd)
|
|||
|
||||
PrintAndLog("\nNo Known Tags Found!\n");
|
||||
if (testRaw=='u' || testRaw=='U') {
|
||||
ans=CheckChipType(cmdp);
|
||||
//ans=CheckChipType(cmdp);
|
||||
//test unknown tag formats (raw mode)0
|
||||
PrintAndLog("\nChecking for Unknown tags:\n");
|
||||
ans=AutoCorrelate(GraphBuffer, GraphBuffer, GraphTraceLen, 4000, false, false);
|
||||
|
|
|
@ -571,7 +571,7 @@ int EM4x50Read(const char *Cmd, bool verbose)
|
|||
start = skip;
|
||||
snprintf(tmp2, sizeof(tmp2),"%d %d 1000 %d", clk, invert, clk*47);
|
||||
// save GraphBuffer - to restore it later
|
||||
save_restoreGB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
// get rid of leading crap
|
||||
snprintf(tmp, sizeof(tmp), "%i", skip);
|
||||
CmdLtrim(tmp);
|
||||
|
@ -599,7 +599,7 @@ int EM4x50Read(const char *Cmd, bool verbose)
|
|||
phaseoff = 0;
|
||||
i += 2;
|
||||
if (ASKDemod(tmp2, false, false, 1) < 1) {
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return 0;
|
||||
}
|
||||
//set DemodBufferLen to just one block
|
||||
|
@ -638,7 +638,7 @@ int EM4x50Read(const char *Cmd, bool verbose)
|
|||
}
|
||||
|
||||
//restore GraphBuffer
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
return (int)AllPTest;
|
||||
}
|
||||
|
||||
|
|
|
@ -419,23 +419,23 @@ bool DecodeT55xxBlock(){
|
|||
break;
|
||||
case DEMOD_PSK1:
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
save_restoreGB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
CmdLtrim("160");
|
||||
snprintf(cmdStr, sizeof(buf),"%d %d 6", bitRate[config.bitrate], config.inverted );
|
||||
ans = PSKDemod(cmdStr, false);
|
||||
//undo trim samples
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
break;
|
||||
case DEMOD_PSK2: //inverted won't affect this
|
||||
case DEMOD_PSK3: //not fully implemented
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
save_restoreGB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
CmdLtrim("160");
|
||||
snprintf(cmdStr, sizeof(buf),"%d 0 6", bitRate[config.bitrate] );
|
||||
ans = PSKDemod(cmdStr, false);
|
||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||
//undo trim samples
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
break;
|
||||
case DEMOD_NRZ:
|
||||
snprintf(cmdStr, sizeof(buf),"%d %d 1", bitRate[config.bitrate], config.inverted );
|
||||
|
@ -594,7 +594,7 @@ bool tryDetectModulation(){
|
|||
clk = GetPskClock("", false, false);
|
||||
if (clk>0) {
|
||||
// allow undo
|
||||
save_restoreGB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
|
||||
CmdLtrim("160");
|
||||
if ( PSKDemod("0 0 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
|
||||
|
@ -638,7 +638,7 @@ bool tryDetectModulation(){
|
|||
}
|
||||
} // inverse waves does not affect this demod
|
||||
//undo trim samples
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
}
|
||||
}
|
||||
if ( hits == 1) {
|
||||
|
|
|
@ -53,16 +53,19 @@ int ClearGraph(int redraw)
|
|||
void save_restoreGB(uint8_t saveOpt)
|
||||
{
|
||||
static int SavedGB[MAX_GRAPH_TRACE_LEN];
|
||||
static int SavedGBlen;
|
||||
static int SavedGBlen=0;
|
||||
static bool GB_Saved = false;
|
||||
static int SavedGridOffsetAdj=0;
|
||||
|
||||
if (saveOpt==1) { //save
|
||||
if (saveOpt == GRAPH_SAVE) { //save
|
||||
memcpy(SavedGB, GraphBuffer, sizeof(GraphBuffer));
|
||||
SavedGBlen = GraphTraceLen;
|
||||
GB_Saved=true;
|
||||
SavedGridOffsetAdj = GridOffset;
|
||||
} else if (GB_Saved) { //restore
|
||||
memcpy(GraphBuffer, SavedGB, sizeof(GraphBuffer));
|
||||
GraphTraceLen = SavedGBlen;
|
||||
GridOffset = SavedGridOffsetAdj;
|
||||
RepaintGraphWindow();
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -32,6 +32,8 @@ void DetectHighLowInGraph(int *high, int *low, bool addFuzz);
|
|||
|
||||
// Max graph trace len: 40000 (bigbuf) * 8 (at 1 bit per sample)
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8 )
|
||||
#define GRAPH_SAVE 1
|
||||
#define GRAPH_RESTORE 0
|
||||
|
||||
extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||
extern int GraphTraceLen;
|
||||
|
|
|
@ -40,6 +40,8 @@ extern int AutoCorrelate(const int *in, int *out, size_t len, int window, bool S
|
|||
extern int directionalThreshold(const int* in, int *out, size_t len, int8_t up, int8_t down);
|
||||
extern void save_restoreGB(uint8_t saveOpt);
|
||||
|
||||
#define GRAPH_SAVE 1
|
||||
#define GRAPH_RESTORE 0
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
extern size_t DemodBufferLen;
|
||||
|
|
|
@ -32,7 +32,7 @@ bool g_useOverlays = false;
|
|||
int g_absVMax = 0;
|
||||
int startMax;
|
||||
int PageWidth;
|
||||
|
||||
int unlockStart = 0;
|
||||
|
||||
void ProxGuiQT::ShowGraphWindow(void)
|
||||
{
|
||||
|
@ -119,13 +119,13 @@ ProxGuiQT::~ProxGuiQT(void)
|
|||
void ProxWidget::applyOperation()
|
||||
{
|
||||
//printf("ApplyOperation()");
|
||||
save_restoreGB(1);
|
||||
save_restoreGB(GRAPH_SAVE);
|
||||
memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen);
|
||||
RepaintGraphWindow();
|
||||
}
|
||||
void ProxWidget::stickOperation()
|
||||
{
|
||||
save_restoreGB(0);
|
||||
save_restoreGB(GRAPH_RESTORE);
|
||||
//printf("stickOperation()");
|
||||
}
|
||||
void ProxWidget::vchange_autocorr(int v)
|
||||
|
@ -434,11 +434,22 @@ void Plot::PlotGraph(int *buffer, int len, QRect plotRect, QRect annotationRect,
|
|||
|
||||
void Plot::plotGridLines(QPainter* painter,QRect r)
|
||||
{
|
||||
// set GridOffset
|
||||
if (PlotGridX <= 0) return;
|
||||
int offset = GridOffset;
|
||||
if (GridLocked && PlotGridX) {
|
||||
offset = GridOffset + PlotGridX - (GraphStart % PlotGridX);
|
||||
} else if (!GridLocked && GraphStart > 0 && PlotGridX) {
|
||||
offset = PlotGridX-((GraphStart - offset) % PlotGridX) + GraphStart - unlockStart;
|
||||
}
|
||||
offset %= PlotGridX;
|
||||
if (offset < 0) offset += PlotGridX;
|
||||
|
||||
int i;
|
||||
int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
|
||||
int grid_delta_y = PlotGridY;
|
||||
if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
|
||||
for(i = (GridOffset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
|
||||
for(i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
|
||||
painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
|
||||
}
|
||||
}
|
||||
|
@ -581,9 +592,6 @@ void Plot::mouseMoveEvent(QMouseEvent *event)
|
|||
void Plot::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int offset;
|
||||
int gridchanged;
|
||||
|
||||
gridchanged= 0;
|
||||
|
||||
if(event->modifiers() & Qt::ShiftModifier) {
|
||||
if (PlotGridX)
|
||||
|
@ -611,53 +619,18 @@ void Plot::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
case Qt::Key_Right:
|
||||
if(GraphPixelsPerPoint < 20) {
|
||||
if (PlotGridX && GridLocked && GraphStart < startMax){
|
||||
GridOffset -= offset;
|
||||
GridOffset %= PlotGridX;
|
||||
gridchanged= 1;
|
||||
}
|
||||
GraphStart += offset;
|
||||
} else {
|
||||
if (PlotGridX && GridLocked && GraphStart < startMax){
|
||||
GridOffset--;
|
||||
GridOffset %= PlotGridX;
|
||||
gridchanged= 1;
|
||||
}
|
||||
GraphStart++;
|
||||
}
|
||||
if(GridOffset < 0) {
|
||||
GridOffset += PlotGridX;
|
||||
}
|
||||
if (gridchanged)
|
||||
if (GraphStart > startMax) {
|
||||
GridOffset += (GraphStart - startMax);
|
||||
GridOffset %= PlotGridX;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
if(GraphPixelsPerPoint < 20) {
|
||||
if (PlotGridX && GridLocked && GraphStart > 0){
|
||||
GridOffset += offset;
|
||||
GridOffset %= PlotGridX;
|
||||
gridchanged= 1;
|
||||
}
|
||||
GraphStart -= offset;
|
||||
} else {
|
||||
if (PlotGridX && GridLocked && GraphStart > 0){
|
||||
GridOffset++;
|
||||
GridOffset %= PlotGridX;
|
||||
gridchanged= 1;
|
||||
}
|
||||
GraphStart--;
|
||||
}
|
||||
if (gridchanged){
|
||||
if (GraphStart < 0)
|
||||
GridOffset += GraphStart;
|
||||
if(GridOffset < 0)
|
||||
GridOffset += PlotGridX;
|
||||
GridOffset %= PlotGridX;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_G:
|
||||
|
@ -693,6 +666,10 @@ void Plot::keyPressEvent(QKeyEvent *event)
|
|||
|
||||
case Qt::Key_L:
|
||||
GridLocked = !GridLocked;
|
||||
if (GridLocked)
|
||||
GridOffset += (GraphStart - unlockStart);
|
||||
else
|
||||
unlockStart = GraphStart;
|
||||
break;
|
||||
|
||||
case Qt::Key_Q:
|
||||
|
|
Loading…
Reference in a new issue