mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 18:57:12 +08:00
nested structs on the sender, for more lean packet size computation
This commit is contained in:
parent
270afb89aa
commit
fda181890c
1 changed files with 6 additions and 3 deletions
|
@ -169,15 +169,18 @@ static int usart_rx(uint8_t *data, size_t *len, uint32_t waittime) {
|
||||||
|
|
||||||
static int usart_txrx(uint8_t *srcdata, size_t srclen, uint8_t *dstdata, size_t *dstlen, uint32_t waittime) {
|
static int usart_txrx(uint8_t *srcdata, size_t srclen, uint8_t *dstdata, size_t *dstlen, uint32_t waittime) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
struct {
|
struct payload_header {
|
||||||
uint32_t waittime;
|
uint32_t waittime;
|
||||||
|
} PACKED;
|
||||||
|
struct {
|
||||||
|
struct payload_header header;
|
||||||
uint8_t data[PM3_CMD_DATA_SIZE - sizeof(uint32_t)];
|
uint8_t data[PM3_CMD_DATA_SIZE - sizeof(uint32_t)];
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
payload.waittime = waittime;
|
payload.header.waittime = waittime;
|
||||||
if (srclen >= sizeof(payload.data))
|
if (srclen >= sizeof(payload.data))
|
||||||
return PM3_EOVFLOW;
|
return PM3_EOVFLOW;
|
||||||
memcpy(payload.data, srcdata, srclen);
|
memcpy(payload.data, srcdata, srclen);
|
||||||
SendCommandNG(CMD_USART_TXRX, (uint8_t *)&payload, srclen + sizeof(payload.waittime));
|
SendCommandNG(CMD_USART_TXRX, (uint8_t *)&payload, srclen + sizeof(payload.header));
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_USART_TXRX, &resp, waittime + 500)) {
|
if (!WaitForResponseTimeout(CMD_USART_TXRX, &resp, waittime + 500)) {
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
|
|
Loading…
Reference in a new issue