Add support for trigger threshold
This commit is contained in:
2 files changed
+44
-17
No files matched your search
+14
-7
@@ -402,10 +402,6 @@ __attribute__((force_align_arg_pointer))
|
||||
uint8_t dummyData[64];
|
||||
uint32_t dummyLen;
|
||||
uart_receive(sp, dummyData, sizeof(dummyData), &dummyLen);
|
||||
|
||||
// set the buffer as undefined
|
||||
// comm_raw_data == NULL is used in SetCommunicationReceiveMode()
|
||||
__atomic_store_n(&comm_raw_data, NULL, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
} else {
|
||||
if (is_receiving_raw_last) {
|
||||
@@ -856,6 +852,12 @@ size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, boo
|
||||
// send anything to stop the transfer
|
||||
PrintAndLogEx(INFO, "Stopping");
|
||||
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
||||
|
||||
// for ms_timeout == -1, pos < len might always be true
|
||||
// so user need a spectial way to break this loop
|
||||
if (ms_timeout == (size_t) - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos = __atomic_load_n(&comm_raw_pos, __ATOMIC_SEQ_CST);
|
||||
@@ -863,7 +865,8 @@ size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, boo
|
||||
// check the timeout if pos is not updated
|
||||
if (last_pos == pos) {
|
||||
uint64_t tmp_clk = __atomic_load_n(&timeout_start_time, __ATOMIC_SEQ_CST);
|
||||
if ((msclock() - tmp_clk > ms_timeout)) {
|
||||
// if ms_timeout == -1, the loop can only be breaked by pressing Enter or receiving enough data
|
||||
if ((ms_timeout != (size_t) - 1) && (msclock() - tmp_clk > ms_timeout)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -877,13 +880,17 @@ size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, boo
|
||||
last_pos = pos;
|
||||
msleep(10);
|
||||
}
|
||||
if (pos == len) {
|
||||
if (pos == len && (ms_timeout != (size_t) - 1)) {
|
||||
// if ms_timeout != -1, when the desired data is received, tell the arm side
|
||||
// to stop the current process, and wait for some time to make sure the process
|
||||
// has been stopped
|
||||
// if ms_timeout == -1, the user might not want to break the existing process
|
||||
// on the arm side
|
||||
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
|
||||
msleep(ms_timeout);
|
||||
}
|
||||
SetCommunicationReceiveMode(false);
|
||||
pos = __atomic_load_n(&comm_raw_pos, __ATOMIC_SEQ_CST);
|
||||
PrintAndLogEx(INFO, "Done: [%zu/%zu]", pos, len);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user