Command Organization in cmddata.c

Getting ready to do some refactoring!
This commit is contained in:
Jacob Litewski 2024-04-11 20:06:36 -04:00
commit 6b72e39f51
2 changed files with 56 additions and 53 deletions

View file

@ -3790,33 +3790,35 @@ static int CmdXor(const char *Cmd) {
static command_t CommandTable[] = {
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("General") "-------------------------"},
{"help", CmdHelp, AlwaysAvailable, "This help"},
{"plot", CmdPlot, AlwaysAvailable, "Show graph window"},
{"hide", CmdHide, AlwaysAvailable, "Hide graph window"},
{"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"},
{"save", CmdSave, AlwaysAvailable, "Save signal trace data"},
{"clear", CmdBuffClear, AlwaysAvailable, "Clears various buffers used by the graph window"},
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Modulation") "-------------------------"},
{"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"},
{"detectclock", CmdDetectClockRate, AlwaysAvailable, "Detect ASK, FSK, NRZ, PSK clock rate of wave in GraphBuffer"},
{"biphaserawdecode", CmdBiphaseDecodeRaw, AlwaysAvailable, "Biphase decode bin stream in DemodBuffer"},
{"fsktonrz", CmdFSKToNRZ, AlwaysAvailable, "Convert fsk2 to nrz wave for alternate fsk demodulating (for weak fsk)"},
{"manrawdecode", Cmdmandecoderaw, AlwaysAvailable, "Manchester decode binary stream in DemodBuffer"},
{"modulation", CmdDataModulationSearch, AlwaysAvailable, "Identify LF signal for clock and modulation"},
{"rawdemod", CmdRawDemod, AlwaysAvailable, "Demodulate the data in the GraphBuffer and output binary"},
{"-----------", CmdHelp, AlwaysAvailable, "------------------------- " _CYAN_("Graph") "-------------------------"},
{"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"},
{"askedgedetect", CmdAskEdgeDetect, AlwaysAvailable, "Adjust Graph for manual ASK demod"},
{"autocorr", CmdAutoCorr, AlwaysAvailable, "Autocorrelation over window"},
{"cthreshold", CmdCenterThreshold, AlwaysAvailable, "Average out all values between"},
{"dirthreshold", CmdDirectionalThreshold, AlwaysAvailable, "Max rising higher up-thres/ Min falling lower down-thres"},
{"decimate", CmdDecimate, AlwaysAvailable, "Decimate samples"},
{"envelope", CmdEnvelope, AlwaysAvailable, "Generate square envelope of samples"},
{"decimate", CmdDecimate, AlwaysAvailable, "Decimate samples"},
{"undecimate", CmdUndecimate, AlwaysAvailable, "Un-decimate samples"},
{"hide", CmdHide, AlwaysAvailable, "Hide graph window"},
{"hpf", CmdHpf, AlwaysAvailable, "Remove DC offset from trace"},
{"iir", CmdDataIIR, AlwaysAvailable, "Apply IIR buttersworth filter on plot data"},
{"grid", CmdGrid, AlwaysAvailable, "overlay grid on graph window"},
{"ltrim", CmdLtrim, AlwaysAvailable, "Trim samples from left of trace"},
{"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"},
{"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"},
{"plot", CmdPlot, AlwaysAvailable, "Show graph window"},
{"cthreshold", CmdCenterThreshold, AlwaysAvailable, "Average out all values between"},
{"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"},
{"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"},
{"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set blue and orange marker in graph window"},
{"shiftgraphzero", CmdGraphShiftZero, AlwaysAvailable, "Shift 0 for Graphed wave + or - shift value"},
{"timescale", CmdTimeScale, AlwaysAvailable, "Set cursor display timescale"},
@ -3830,16 +3832,13 @@ static command_t CommandTable[] = {
{"bin2hex", Cmdbin2hex, AlwaysAvailable, "Converts binary to hexadecimal"},
{"bitsamples", CmdBitsamples, IfPm3Present, "Get raw samples as bitstring"},
{"bmap", CmdBinaryMap, AlwaysAvailable, "Convert hex value according a binary template"},
{"clear", CmdBuffClear, AlwaysAvailable, "Clears bigbuf on deviceside and graph window"},
{"crypto", CmdCryptography, AlwaysAvailable, "Encrypt and decrypt data"},
{"diff", CmdDiff, AlwaysAvailable, "Diff of input files"},
{"hexsamples", CmdHexsamples, IfPm3Present, "Dump big buffer as hex bytes"},
{"hex2bin", Cmdhex2bin, AlwaysAvailable, "Converts hexadecimal to binary"},
{"load", CmdLoad, AlwaysAvailable, "Load contents of file into graph window"},
{"num", CmdNumCon, AlwaysAvailable, "Converts dec/hex/bin"},
{"print", CmdPrintDemodBuff, AlwaysAvailable, "Print the data in the DemodBuffer"},
{"samples", CmdSamples, IfPm3Present, "Get raw samples for graph window ( GraphBuffer )"},
{"save", CmdSave, AlwaysAvailable, "Save signal trace data ( GraphBuffer )"},
{"setdebugmode", CmdSetDebugMode, AlwaysAvailable, "Set Debugging Level on client side"},
{"xor", CmdXor, AlwaysAvailable, "Xor a input string"},
{NULL, NULL, NULL, NULL}

View file

@ -95,6 +95,7 @@ void save_restoreGB(uint8_t saveOpt) {
Savedg_GridOffsetAdj = g_GridOffset;
} else if (GB_Saved) { //restore
memcpy(g_GraphBuffer, SavedGB, sizeof(g_GraphBuffer));
memcpy(g_OperationBuffer, SavedGB, sizeof(g_OperationBuffer));
g_GraphTraceLen = SavedGBlen;
g_GridOffset = Savedg_GridOffsetAdj;
RepaintGraphWindow();
@ -106,11 +107,14 @@ void setGraphBuf(const uint8_t *src, size_t size) {
ClearGraph(false);
if (size > MAX_GRAPH_TRACE_LEN)
if (size > MAX_GRAPH_TRACE_LEN) {
size = MAX_GRAPH_TRACE_LEN;
}
for (size_t i = 0; i < size; ++i)
for (size_t i = 0; i < size; ++i) {
g_GraphBuffer[i] = src[i] - 128;
g_OperationBuffer[i] = src[i] - 128;
}
g_GraphTraceLen = size;
RepaintGraphWindow();