Add SendCommandOLD

This commit is contained in:
Philippe Teuwen 2019-04-18 22:19:28 +02:00
parent b860cc6eaf
commit 9bd59a8d40
3 changed files with 18 additions and 8 deletions

View file

@ -419,8 +419,7 @@ static int CmdStatus(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
PacketResponseNG resp;
PacketCommandOLD c = {CMD_STATUS, {0, 0, 0}, {{0}}};
SendCommand(&c);
SendCommandOLD(CMD_STATUS, 0, 0, 0, NULL, 0);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1900))
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
return 0;
@ -430,12 +429,11 @@ static int CmdPing(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
PacketResponseNG resp;
PacketCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
SendCommandOLD(CMD_PING, 0, 0, 0, NULL, 0);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
PrintAndLogEx(NORMAL, "Ping successful");
PrintAndLogEx(NORMAL, "Ping " _GREEN_("successful"));
else
PrintAndLogEx(NORMAL, "Ping failed");
PrintAndLogEx(NORMAL, "Ping " _RED_("failed"));
return 0;
}
@ -447,10 +445,9 @@ static int CmdPingNG(const char *Cmd) {
clearCommandBuffer();
PacketResponseNG resp;
uint8_t data[USB_CMD_DATA_SIZE] = {0};
uint16_t cmd = CMD_PING;
for (uint16_t i = 0; i < len; i++)
data[i] = i & 0xFF;
SendCommandNG(cmd, data, len);
SendCommandNG(CMD_PING, data, len);
if (WaitForResponseTimeout(CMD_PING, &resp, 1000)) {
bool error = false;
if (len)

View file

@ -94,6 +94,18 @@ void SendCommand(PacketCommandOLD *c) {
//__atomic_test_and_set(&txcmd_pending, __ATOMIC_SEQ_CST);
}
// Let's move slowly to an API closer to SendCommandNG
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
PacketCommandOLD c = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
c.cmd = cmd;
c.arg[0] = arg0;
c.arg[1] = arg1;
c.arg[2] = arg2;
if (len && data)
memcpy(&c.d, data, len);
SendCommand(&c);
}
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
#ifdef COMMS_DEBUG

View file

@ -55,6 +55,7 @@ bool IsOffline(void);
void *uart_receiver(void *targ);
void SendCommand(PacketCommandOLD *c);
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
void clearCommandBuffer(void);