FIX: 'data load' - now loads large files again (TITEST.txt)

This commit is contained in:
iceman1001 2019-03-09 20:47:57 +01:00
parent 64a977e514
commit e8d15d0c18
2 changed files with 8 additions and 6 deletions

View file

@ -1600,19 +1600,23 @@ int CmdLoad(const char *Cmd) {
len = strlen(Cmd);
if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;
memcpy(filename, Cmd, len);
FILE *f = fopen(filename, "r");
if (!f) {
PrintAndLogEx(WARNING, "couldn't open '%s'", filename);
return 0;
}
GraphTraceLen = 0;
char line[80];
while (fgets(line, sizeof (line), f)) {
GraphBuffer[GraphTraceLen] = atoi(line);
GraphTraceLen++;
if ( GraphTraceLen >= MAX_GRAPH_TRACE_LEN )
break;
}
if (f)
fclose(f);
@ -1620,11 +1624,9 @@ int CmdLoad(const char *Cmd) {
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
// set signal properties low/high/mean/amplitude and is_noise detection
removeSignalOffset(bits, size);
// push it back to graph
setGraphBuf(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
setClockGrid(0,0);

View file

@ -67,7 +67,7 @@ void setGraphBuf(uint8_t *buf, size_t size) {
if ( size > MAX_GRAPH_TRACE_LEN )
size = MAX_GRAPH_TRACE_LEN;
for (uint16_t i = 0; i < size; ++i)
for (uint32_t i = 0; i < size; ++i)
GraphBuffer[i] = buf[i] - 128;
GraphTraceLen = size;