mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-15 01:33:00 -07:00
commit
1adb2023ce
7 changed files with 214 additions and 194 deletions
|
@ -667,6 +667,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
|||
break;
|
||||
case CMD_T55XX_WRITE_BLOCK:
|
||||
T55xxWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
break;
|
||||
case CMD_T55XX_READ_TRACE:
|
||||
T55xxReadTrace();
|
||||
|
|
|
@ -399,14 +399,10 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
|
|||
#define OPEN_COIL() HIGH(GPIO_SSC_DOUT)
|
||||
|
||||
i = 0;
|
||||
byte_t rx[sizeof(UsbCommand)]; // Storage for usb_read call in loop
|
||||
for(;;) {
|
||||
//wait until SSC_CLK goes HIGH
|
||||
while(!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
|
||||
// Craig Young - Adding a usb_read() here to avoid abort on empty UsbCommand
|
||||
// My OS X client does this preventing simulation.
|
||||
// Performance hit should be non-existent since the read is only performed if usb_poll is true
|
||||
if(BUTTON_PRESS() || (usb_poll() && usb_read(rx,sizeof(UsbCommand)))) {
|
||||
if(BUTTON_PRESS() || (usb_poll_validate_length() )) {
|
||||
DbpString("Stopped");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -406,16 +406,10 @@ int CmdVersion(const char *Cmd)
|
|||
{
|
||||
|
||||
UsbCommand c = {CMD_VERSION};
|
||||
static UsbCommand resp = {0, {0, 0, 0}};
|
||||
UsbCommand resp = {0, {0, 0, 0}};
|
||||
|
||||
if (resp.arg[0] == 0 && resp.arg[1] == 0) { // no cached information available
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1000) && Cmd != NULL) {
|
||||
PrintAndLog("Prox/RFID mark3 RFID instrument");
|
||||
PrintAndLog((char*)resp.d.asBytes);
|
||||
lookupChipID(resp.arg[0], resp.arg[1]);
|
||||
}
|
||||
} else if (Cmd != NULL) {
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
|
||||
PrintAndLog("Prox/RFID mark3 RFID instrument");
|
||||
PrintAndLog((char*)resp.d.asBytes);
|
||||
lookupChipID(resp.arg[0], resp.arg[1]);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "cmdparser.h" // CmdsParse, CmdsHelp
|
||||
#include "cmdlfawid.h" // AWID function declarations
|
||||
#include "lfdemod.h" // parityTest
|
||||
|
||||
#include "cmdmain.h"
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
||||
|
@ -176,8 +176,7 @@ int CmdAWIDClone(const char *Cmd)
|
|||
uint32_t fc=0,cn=0,blocks[4] = {0x00107060, 0, 0, 0x11111111}, i=0;
|
||||
uint8_t BitStream[12];
|
||||
uint8_t *BS=BitStream;
|
||||
UsbCommand c;
|
||||
|
||||
UsbCommand c, resp;
|
||||
|
||||
if (sscanf(Cmd, "%u %u", &fc, &cn ) != 2) {
|
||||
return usage_lf_awid_clone();
|
||||
|
@ -206,6 +205,11 @@ int CmdAWIDClone(const char *Cmd)
|
|||
c.arg[1] = i;
|
||||
c.arg[2] = 0;
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)){
|
||||
PrintAndLog("Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -242,6 +242,7 @@ int CmdT55xxReadBlock(const char *Cmd) {
|
|||
c.d.asBytes[0] = 0x1;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
|
||||
PrintAndLog("command execution time out");
|
||||
|
@ -670,6 +671,7 @@ int CmdT55xxWriteBlock(const char *Cmd)
|
|||
}
|
||||
|
||||
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};
|
||||
UsbCommand resp;
|
||||
c.d.asBytes[0] = 0x0;
|
||||
|
||||
PrintAndLog("Writing to block: %d data : 0x%08X", block, data);
|
||||
|
@ -680,7 +682,12 @@ int CmdT55xxWriteBlock(const char *Cmd)
|
|||
c.d.asBytes[0] = 0x1;
|
||||
PrintAndLog("pwd : 0x%08X", password);
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)){
|
||||
PrintAndLog("Error occurred, device did not ACK write operation. (May be due to old firmware)");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -878,6 +885,7 @@ int AquireData( uint8_t block ){
|
|||
// c.d.asBytes[0] = 0x1;
|
||||
// }
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
|
||||
PrintAndLog("command execution time out");
|
||||
|
|
|
@ -293,6 +293,22 @@ bool usb_poll()
|
|||
return (pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank);
|
||||
}
|
||||
|
||||
/**
|
||||
In github PR #129, some users appears to get a false positive from
|
||||
usb_poll, which returns true, but the usb_read operation
|
||||
still returns 0.
|
||||
This check is basically the same as above, but also checks
|
||||
that the length available to read is non-zero, thus hopefully fixes the
|
||||
bug.
|
||||
**/
|
||||
bool usb_poll_validate_length()
|
||||
{
|
||||
|
||||
if (!usb_check()) return false;
|
||||
if (!(pUdp->UDP_CSR[AT91C_EP_OUT] & btReceiveBank)) return false;
|
||||
return (pUdp->UDP_CSR[AT91C_EP_OUT] >> 16) > 0;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
//* \fn usb_read
|
||||
//* \brief Read available data from Endpoint OUT
|
||||
|
|
|
@ -41,6 +41,7 @@ void usb_disable();
|
|||
void usb_enable();
|
||||
bool usb_check();
|
||||
bool usb_poll();
|
||||
bool usb_poll_validate_length();
|
||||
uint32_t usb_read(byte_t* data, size_t len);
|
||||
uint32_t usb_write(const byte_t* data, const size_t len);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue