From f49d7e6d3984a645db8e167b537b25141f0d072c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 8 May 2019 01:32:32 +0200 Subject: [PATCH] remove SendCommand --- client/comms.c | 29 ++++++++++++----------------- client/comms.h | 1 - client/scripting.c | 21 --------------------- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/client/comms.c b/client/comms.c index 1fb59757b..a1609eac3 100644 --- a/client/comms.c +++ b/client/comms.c @@ -57,15 +57,22 @@ static uint64_t timeout_start_time; static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd); -void SendCommand(PacketCommandOLD *c) { +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); #ifdef COMMS_DEBUG PrintAndLogEx(NORMAL, "Sending %s", "OLD"); #endif #ifdef COMMS_DEBUG_RAW - print_hex_break((uint8_t *)&c->cmd, sizeof(c->cmd), 32); - print_hex_break((uint8_t *)&c->arg, sizeof(c->arg), 32); - print_hex_break((uint8_t *)&c->d, sizeof(c->d), 32); + print_hex_break((uint8_t *)&c.cmd, sizeof(c.cmd), 32); + print_hex_break((uint8_t *)&c.arg, sizeof(c.arg), 32); + print_hex_break((uint8_t *)&c.d, sizeof(c.d), 32); #endif if (!session.pm3_present) { @@ -83,7 +90,7 @@ void SendCommand(PacketCommandOLD *c) { pthread_cond_wait(&txBufferSig, &txBufferMutex); } - txBuffer = *c; + txBuffer = c; txBuffer_pending = true; // tell communication thread that a new command can be send @@ -94,18 +101,6 @@ 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); -} - static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool ng) { #ifdef COMMS_DEBUG PrintAndLogEx(NORMAL, "Sending %s", ng ? "NG" : "MIX"); diff --git a/client/comms.h b/client/comms.h index 547a46af6..6505e23d7 100644 --- a/client/comms.h +++ b/client/comms.h @@ -56,7 +56,6 @@ typedef struct { extern communication_arg_t conn; 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 SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len); diff --git a/client/scripting.c b/client/scripting.c index 91fc5b427..87de2c088 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -54,26 +54,6 @@ static int l_fast_push_mode(lua_State *L) { return 1; } -/** - * The following params expected: - * UsbCommand c - *@brief l_SendCommand - * @param L - * @return - */ -static int l_SendCommand(lua_State *L) { - size_t size; - const char *data = luaL_checklstring(L, 1, &size); - if (size != sizeof(PacketCommandOLD)) { - printf("Got data size %d, expected %d", (int) size, (int) sizeof(PacketCommandOLD)); - lua_pushstring(L, "Wrong data size"); - return 1; - } - - SendCommand((PacketCommandOLD *)data); - return 0; -} - /** * The following params expected: * @brief l_SendCommandOLD @@ -1042,7 +1022,6 @@ static int setLuaPath(lua_State *L, const char *path) { int set_pm3_libraries(lua_State *L) { static const luaL_Reg libs[] = { - {"SendCommand", l_SendCommand}, {"SendCommandOLD", l_SendCommandOLD}, {"SendCommandMIX", l_SendCommandMIX}, {"SendCommandNG", l_SendCommandNG},