chg: added clearCommandBuffer();

This commit is contained in:
iceman1001 2017-08-31 15:16:12 +02:00
commit c75ce57dfd

View file

@ -218,6 +218,7 @@ int getUID(uint8_t *buf)
reqlen = AddCrc(req, 3); reqlen = AddCrc(req, 3);
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
@ -284,7 +285,6 @@ int CmdHF15Demod(const char *Cmd)
int i, j; int i, j;
int max = 0, maxPos = 0; int max = 0, maxPos = 0;
int skip = 4; int skip = 4;
if (GraphTraceLen < 1000) return 0; if (GraphTraceLen < 1000) return 0;
@ -360,6 +360,7 @@ int CmdHF15Demod(const char *Cmd)
int CmdHF15Read(const char *Cmd) int CmdHF15Read(const char *Cmd)
{ {
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693}; UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693};
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -368,6 +369,7 @@ int CmdHF15Read(const char *Cmd)
int CmdHF15Record(const char *Cmd) int CmdHF15Record(const char *Cmd)
{ {
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693}; UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693};
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -389,6 +391,7 @@ int HF15Reader(const char *Cmd, bool verbose)
int CmdHF15Reader(const char *Cmd) int CmdHF15Reader(const char *Cmd)
{ {
UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}}; UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -417,7 +420,7 @@ int CmdHF15Sim(const char *Cmd)
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}}; UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}};
memcpy(c.d.asBytes,uid,8); memcpy(c.d.asBytes,uid,8);
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -427,6 +430,7 @@ int CmdHF15Sim(const char *Cmd)
int CmdHF15Afi(const char *Cmd) int CmdHF15Afi(const char *Cmd)
{ {
UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}}; UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}};
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -460,6 +464,7 @@ int CmdHF15DumpMem(const char*Cmd) {
reqlen = AddCrc(req, 11); reqlen = AddCrc(req, 11);
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
@ -545,6 +550,7 @@ int CmdHF15CmdInquiry(const char *Cmd)
reqlen = AddCrc(req,3); reqlen = AddCrc(req,3);
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) { if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
@ -573,6 +579,7 @@ int CmdHF15CmdDebug( const char *cmd) {
} }
UsbCommand c = {CMD_ISO_15693_DEBUG, {debug, 0, 0}}; UsbCommand c = {CMD_ISO_15693_DEBUG, {debug, 0, 0}};
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }
@ -651,6 +658,7 @@ int CmdHF15CmdRaw (const char *cmd) {
c.arg[2] = reply; c.arg[2] = reply;
memcpy(c.d.asBytes,data,datalen); memcpy(c.d.asBytes,data,datalen);
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (reply) { if (reply) {
@ -806,6 +814,7 @@ int CmdHF15CmdSysinfo(const char *Cmd) {
reqlen = AddCrc(req, reqlen); reqlen = AddCrc(req, reqlen);
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1000) && resp.arg[0]>2) {
@ -907,6 +916,7 @@ int CmdHF15CmdReadmulti(const char *Cmd) {
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) {
@ -980,6 +990,7 @@ int CmdHF15CmdRead(const char *Cmd) {
c.arg[0] = reqlen; c.arg[0] = reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && resp.arg[0]>2) {
@ -1072,7 +1083,7 @@ int CmdHF15CmdWrite(const char *Cmd) {
reqlen=AddCrc(req,reqlen); reqlen=AddCrc(req,reqlen);
c.arg[0]=reqlen; c.arg[0]=reqlen;
clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK,&resp,2000) && resp.arg[0]>2) { if (WaitForResponseTimeout(CMD_ACK,&resp,2000) && resp.arg[0]>2) {
@ -1093,15 +1104,10 @@ int CmdHF15CmdWrite(const char *Cmd) {
return 0; return 0;
} }
static command_t CommandTable15Cmd[] = {
static command_t CommandTable15Cmd[] =
{
{"help", CmdHF15CmdHelp, 1, "This Help"}, {"help", CmdHF15CmdHelp, 1, "This Help"},
{"inquiry", CmdHF15CmdInquiry, 0, "Search for tags in range"}, {"inquiry", CmdHF15CmdInquiry, 0, "Search for tags in range"},
/* // {"select", CmdHF15CmdSelect, 0, "Select an tag with a specific UID for further commands"},
{"select", CmdHF15CmdSelect, 0, "Select an tag with a specific UID for further commands"},
*/
{"read", CmdHF15CmdRead, 0, "Read a block"}, {"read", CmdHF15CmdRead, 0, "Read a block"},
{"write", CmdHF15CmdWrite, 0, "Write a block"}, {"write", CmdHF15CmdWrite, 0, "Write a block"},
{"readmulti", CmdHF15CmdReadmulti, 0, "Reads multiple Blocks"}, {"readmulti", CmdHF15CmdReadmulti, 0, "Reads multiple Blocks"},
@ -1111,14 +1117,12 @@ static command_t CommandTable15Cmd[] =
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };
int CmdHF15Cmd(const char *Cmd) int CmdHF15Cmd(const char *Cmd) {
{
CmdsParse(CommandTable15Cmd, Cmd); CmdsParse(CommandTable15Cmd, Cmd);
return 0; return 0;
} }
int CmdHF15CmdHelp(const char *Cmd) int CmdHF15CmdHelp(const char *Cmd) {
{
CmdsHelp(CommandTable15Cmd); CmdsHelp(CommandTable15Cmd);
return 0; return 0;
} }