Rename few stuff for consistency
This commit is contained in:
@@ -260,9 +260,9 @@ fail:
|
||||
|
||||
// Get the state of the proxmark, backwards compatible
|
||||
static int get_proxmark_state(uint32_t *state) {
|
||||
UsbCommand c = {CMD_DEVICE_INFO};
|
||||
PacketCommandOLD c = {CMD_DEVICE_INFO};
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
PacketResponseOLD resp;
|
||||
ReceiveCommand(&resp);
|
||||
|
||||
// Three outcomes:
|
||||
@@ -303,7 +303,7 @@ static int enter_bootloader(void) {
|
||||
|
||||
if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
|
||||
fprintf(stderr, "Entering bootloader...\n");
|
||||
UsbCommand c;
|
||||
PacketCommandOLD c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
|
||||
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
|
||||
@@ -338,7 +338,7 @@ static int enter_bootloader(void) {
|
||||
}
|
||||
|
||||
static int wait_for_ack(void) {
|
||||
UsbCommand ack;
|
||||
PacketResponseOLD ack;
|
||||
ReceiveCommand(&ack);
|
||||
if (ack.cmd != CMD_ACK) {
|
||||
printf("Error: Unexpected reply 0x%04x (expected ACK)\n", ack.cmd);
|
||||
@@ -360,7 +360,7 @@ int flash_start_flashing(int enable_bl_writes) {
|
||||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
|
||||
// This command is stupid. Why the heck does it care which area we're
|
||||
// flashing, as long as it's not the bootloader area? The mind boggles.
|
||||
UsbCommand c = {CMD_START_FLASH};
|
||||
PacketCommandOLD c = {CMD_START_FLASH};
|
||||
|
||||
if (enable_bl_writes) {
|
||||
c.arg[0] = FLASH_START;
|
||||
@@ -387,7 +387,7 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
||||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
memcpy(block_buf, data, length);
|
||||
|
||||
UsbCommand c = {CMD_SETUP_WRITE};
|
||||
PacketCommandOLD c = {CMD_SETUP_WRITE};
|
||||
for (int i = 0; i < 240; i += 48) {
|
||||
memcpy(c.d.asBytes, block_buf + i, 48);
|
||||
c.arg[0] = i / 4;
|
||||
@@ -458,7 +458,7 @@ void flash_free(flash_file_t *ctx) {
|
||||
|
||||
// just reset the unit
|
||||
int flash_stop_flashing(void) {
|
||||
UsbCommand c = {CMD_HARDWARE_RESET};
|
||||
PacketCommandOLD c = {CMD_HARDWARE_RESET};
|
||||
SendCommand(&c);
|
||||
msleep(100);
|
||||
return 0;
|
||||
|
||||
@@ -20,14 +20,14 @@ static unsigned int claimed_iface = 0;
|
||||
unsigned char return_on_error = 0;
|
||||
unsigned char error_occured = 0;
|
||||
|
||||
void SendCommand(UsbCommand *c) {
|
||||
void SendCommand(PacketCommandOLD *c) {
|
||||
int ret;
|
||||
|
||||
#if 0
|
||||
printf("Sending %d bytes\n", sizeof(UsbCommand));
|
||||
printf("Sending %d bytes\n", sizeof(PacketCommandOLD));
|
||||
#endif
|
||||
|
||||
ret = usb_bulk_write(devh, 0x01, (char *)c, sizeof(UsbCommand), 1000);
|
||||
ret = usb_bulk_write(devh, 0x01, (char *)c, sizeof(PacketCommandOLD), 1000);
|
||||
if (ret < 0) {
|
||||
error_occured = 1;
|
||||
if (return_on_error)
|
||||
@@ -48,11 +48,11 @@ void SendCommand(UsbCommand *c) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ReceiveCommandPoll(UsbCommand *c) {
|
||||
bool ReceiveCommandPoll(PacketResponseOLD *c) {
|
||||
int ret;
|
||||
|
||||
memset(c, 0, sizeof(UsbCommand));
|
||||
ret = usb_bulk_read(devh, 0x82, (char *)c, sizeof(UsbCommand), 500);
|
||||
memset(c, 0, sizeof(PacketResponseOLD));
|
||||
ret = usb_bulk_read(devh, 0x82, (char *)c, sizeof(PacketResponseOLD), 500);
|
||||
if (ret < 0) {
|
||||
if (ret != -ETIMEDOUT) {
|
||||
error_occured = 1;
|
||||
@@ -73,16 +73,16 @@ bool ReceiveCommandPoll(UsbCommand *c) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (ret && (ret < sizeof(UsbCommand))) {
|
||||
if (ret && (ret < sizeof(PacketResponseOLD))) {
|
||||
fprintf(stderr, "Read only %d instead of requested %d bytes!\n",
|
||||
ret, (int)sizeof(UsbCommand));
|
||||
ret, (int)sizeof(PacketResponseOLD));
|
||||
}
|
||||
}
|
||||
|
||||
return ret > 0;
|
||||
}
|
||||
|
||||
void ReceiveCommand(UsbCommand *c) {
|
||||
void ReceiveCommand(PacketResponseOLD *c) {
|
||||
// printf("%s()\n", __FUNCTION__);
|
||||
int retval = 0;
|
||||
do {
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
extern unsigned char return_on_error;
|
||||
extern unsigned char error_occured;
|
||||
|
||||
void SendCommand(UsbCommand *c);
|
||||
bool ReceiveCommandPoll(UsbCommand *c);
|
||||
void ReceiveCommand(UsbCommand *c);
|
||||
void SendCommand(PacketCommand *c);
|
||||
bool ReceiveCommandPoll(PacketCommand *c);
|
||||
void ReceiveCommand(PacketCommand *c);
|
||||
struct usb_dev_handle *FindProxmark(int verbose, unsigned int *iface);
|
||||
struct usb_dev_handle *OpenProxmark(int verbose);
|
||||
void CloseProxmark(void);
|
||||
|
||||
@@ -30,7 +30,16 @@ typedef struct {
|
||||
uint8_t asBytes[48];
|
||||
uint32_t asDwords[12];
|
||||
} d;
|
||||
} PACKED UsbCommand;
|
||||
} PACKED PacketCommandOLD;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmd;
|
||||
uint32_t arg[3];
|
||||
union {
|
||||
uint8_t asBytes[48];
|
||||
uint32_t asDwords[12];
|
||||
} d;
|
||||
} PACKED PacketResponseOLD;
|
||||
|
||||
// For the bootloader
|
||||
#define CMD_DEVICE_INFO 0x0000
|
||||
|
||||
Reference in New Issue
Block a user