This commit is contained in:
Philippe Teuwen 2019-04-16 20:49:32 +02:00
commit 83571f02a0
6 changed files with 23 additions and 24 deletions

View file

@ -1457,9 +1457,9 @@ static void UsbPacketReceived(bool cmd_ng, uint8_t *packet) {
case CMD_PING:
if (cmd_ng) {
#ifdef WITH_FPC_HOST
cmd_send(CMD_ACK, reply_via_fpc, ((uint32_t *)data_ng)[0], ((uint32_t *)data_ng)[(datalen_ng-1)/4], 0, 0);
cmd_send(CMD_ACK, reply_via_fpc, ((uint32_t *)data_ng)[0], ((uint32_t *)data_ng)[(datalen_ng - 1) / 4], 0, 0);
#else
cmd_send(CMD_ACK, 0, ((uint32_t *)data_ng)[0], ((uint32_t *)data_ng)[(c->arg[0]-1)/4], 0, 0);
cmd_send(CMD_ACK, 0, ((uint32_t *)data_ng)[0], ((uint32_t *)data_ng)[(c->arg[0] - 1) / 4], 0, 0);
#endif
} else {
#ifdef WITH_FPC_HOST
@ -1611,9 +1611,9 @@ void __attribute__((noreturn)) AppMain(void) {
}
}
if (!error) {
#ifdef WITH_FPC_HOST
#ifdef WITH_FPC_HOST
reply_via_fpc = false;
#endif
#endif
UsbPacketReceived(true, rx);
}
} else { // Old style command
@ -1623,9 +1623,9 @@ void __attribute__((noreturn)) AppMain(void) {
error = true;
}
if (!error) {
#ifdef WITH_FPC_HOST
#ifdef WITH_FPC_HOST
reply_via_fpc = false;
#endif
#endif
UsbPacketReceived(false, rx);
}
}

View file

@ -448,9 +448,9 @@ static int CmdPingNG(const char *Cmd) {
uint8_t data[USB_CMD_DATA_SIZE] = {0};
uint16_t cmd = CMD_PING;
if (len >= 4)
((uint32_t *)data)[0]=0xAABBCCDD;
((uint32_t *)data)[0] = 0xAABBCCDD;
if (len >= 8)
((uint32_t *)data)[(len-1)/4] = 0xDDCCBBAA;
((uint32_t *)data)[(len - 1) / 4] = 0xDDCCBBAA;
SendCommandNG(cmd, data, len);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
PrintAndLogEx(NORMAL, "PingNG successful");
@ -458,8 +458,7 @@ static int CmdPingNG(const char *Cmd) {
PrintAndLogEx(NORMAL, "%08x -> %08x", 0xAABBCCDD, resp.arg[1]);
if (len >= 8)
PrintAndLogEx(NORMAL, "%08x -> %08x", 0xDDCCBBAA, resp.arg[2]);
}
else
} else
PrintAndLogEx(NORMAL, "PingNG failed");
return 0;
}

View file

@ -87,7 +87,7 @@ void SendCommand(UsbCommand *c) {
//__atomic_test_and_set(&txcmd_pending, __ATOMIC_SEQ_CST);
}
void SendCommandNG(uint16_t cmd, uint8_t* data, size_t len) {
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
#ifdef COMMS_DEBUG
PrintAndLogEx(NORMAL, "Sending %d bytes of payload | cmd %04x\n", len, cmd);

View file

@ -52,7 +52,7 @@ bool IsOffline(void);
void *uart_receiver(void *targ);
void SendCommand(UsbCommand *c);
void SendCommandNG(uint16_t cmd, uint8_t* data, size_t len);
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
void clearCommandBuffer(void);
#define FLASHMODE_SPEED 460800

View file

@ -647,8 +647,8 @@ uint32_t usb_read(uint8_t *data, size_t len) {
}
static uint8_t usb_read_ng_buffer[64];
static size_t usb_read_ng_bufoff=0;
static size_t usb_read_ng_buflen=0;
static size_t usb_read_ng_bufoff = 0;
static size_t usb_read_ng_buflen = 0;
uint32_t usb_read_ng(uint8_t *data, size_t len) {
@ -659,7 +659,7 @@ uint32_t usb_read_ng(uint8_t *data, size_t len) {
uint32_t time_out = 0;
// take first from local buffer
if ( len <= usb_read_ng_buflen ) {
if (len <= usb_read_ng_buflen) {
for (uint32_t i = 0; i < len; i++)
data[nbBytesRcv++] = usb_read_ng_buffer[usb_read_ng_bufoff + i];
usb_read_ng_buflen -= len;