Merge branch 'RfidResearchGroup:master' into work

This commit is contained in:
hazardousvoltage 2023-12-27 00:05:43 -05:00 committed by GitHub
commit c09f3ca8cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Changed `uart_receive()` - Check if TCP connection is lost (@wh201906)
- Change `data detectclock` - now tries all clocks if called w/o any params (@iceman1001)
- Changed `lf search -1u` - improved the autocorrelation detection for unknown signals (@iceman1001)
- Fixed `hf emrtd dump` stack smashing on device side (@iceman1001)

View file

@ -69,6 +69,7 @@ struct timeval timeout = {
static uint32_t newtimeout_value = 0;
static bool newtimeout_pending = false;
static uint8_t rx_empty_counter = 0;
int uart_reconfigure_timeouts(uint32_t value) {
newtimeout_value = value;
@ -727,7 +728,21 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
// Retrieve the count of the incoming bytes
res = ioctl(spu->fd, FIONREAD, &byteCount);
// PrintAndLogEx(ERR, "UART:: RX ioctl res %d byteCount %u", res, byteCount);
if (res < 0) return PM3_ENOTTY;
if (res < 0) {
// error occurred (maybe disconnected)
// This happens when USB-CDC connection is lost
return PM3_ENOTTY;
} else if (byteCount == 0) {
// select() > 0 && byteCount > 0 ===> data available
// select() > 0 && byteCount always equals to 0 ===> maybe disconnected
// This happens when TCP connection is lost
rx_empty_counter++;
if (rx_empty_counter > 3) {
return PM3_ENOTTY;
}
} else {
rx_empty_counter = 0;
}
// For UDP connection, put the incoming data into the buffer and handle them in the next round
if (spu->udpBuffer != NULL) {

View file

@ -49,6 +49,7 @@ struct timeval timeout = {
uint32_t newtimeout_value = 0;
bool newtimeout_pending = false;
uint8_t rx_empty_counter = 0;
int uart_reconfigure_timeouts(uint32_t value) {
newtimeout_value = value;
@ -679,7 +680,21 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
// Retrieve the count of the incoming bytes
res = ioctlsocket(spw->hSocket, FIONREAD, (u_long *)&byteCount);
// PrintAndLogEx(ERR, "UART:: RX ioctl res %d byteCount %u", res, byteCount);
if (res == SOCKET_ERROR) return PM3_ENOTTY;
if (res == SOCKET_ERROR) {
// error occurred (maybe disconnected)
// This happens when USB-CDC connection is lost
return PM3_ENOTTY;
} else if (byteCount == 0) {
// select() > 0 && byteCount > 0 ===> data available
// select() > 0 && byteCount always equals to 0 ===> maybe disconnected
// This happens when TCP connection is lost
rx_empty_counter++;
if (rx_empty_counter > 3) {
return PM3_ENOTTY;
}
} else {
rx_empty_counter = 0;
}
// For UDP connection, put the incoming data into the buffer and handle them in the next round
if (spw->udpBuffer != NULL) {