make style

This commit is contained in:
Philippe Teuwen 2019-04-02 22:32:45 +02:00
commit 64ce30c06c
7 changed files with 43 additions and 42 deletions

View file

@ -1104,10 +1104,10 @@ void UsbPacketReceived(uint8_t *packet, int len) {
*/
char dest[USB_CMD_DATA_SIZE]={'\0'};
char dest[USB_CMD_DATA_SIZE] = {'\0'};
if (usart_dataavailable()) {
Dbprintf("RX DATA!");
uint16_t len = usart_readbuffer((uint8_t*)dest);
uint16_t len = usart_readbuffer((uint8_t *)dest);
dest[len] = '\0';
Dbprintf("RX: %d | %02X %02X %02X %02X %02X %02X %02X %02X ", len, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
}
@ -1130,7 +1130,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
//usb
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
LED_A_OFF();
/*
/*
uint8_t my_rx[sizeof(UsbCommand)];
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
LED_B_INV();
@ -1143,7 +1143,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
}
}
}
*/
*/
//cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
@ -1563,7 +1563,7 @@ void __attribute__((noreturn)) AppMain(void) {
#ifdef WITH_FPC_HOST
reply_via_fpc = 0;
#endif
UsbPacketReceived(rx, sizeof(rx));
UsbPacketReceived(rx, sizeof(rx));
}
#ifdef WITH_FPC_HOST
// Check if there is a FPC packet available

View file

@ -434,11 +434,11 @@ int CmdVersion(const char *Cmd) {
strncat(s, "smartcard; ", sizeof(s) - strlen(s) - 1);
#endif
#ifdef WITH_FPC
#ifdef WITH_FPC_HOST
#ifdef WITH_FPC_HOST
strncat(s, "fpc-host; ", sizeof(s) - strlen(s) - 1);
#else
#else
strncat(s, "fpc; ", sizeof(s) - strlen(s) - 1);
#endif
#endif
#endif
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
PrintAndLogEx(NORMAL, " client: iceman %s \n", s);

View file

@ -1273,68 +1273,69 @@ void printT5555Trace(t5555_tracedata_t data, uint8_t repeat) {
}
static void printT5x7KnownBlock0(uint32_t b0) {
char s[40];
memset(s, 0, sizeof(s));
switch(b0) {
switch (b0) {
case T55X7_DEFAULT_CONFIG_BLOCK:
snprintf(s, sizeof(s)-strlen(s), "T55x7 Default ");
snprintf(s, sizeof(s) - strlen(s), "T55x7 Default ");
break;
case T55X7_RAW_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "T55x7 Raw ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "T55x7 Raw ");
break;
case T55X7_EM_UNIQUE_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "EM Unique ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "EM Unique ");
break;
/*
/*
case T55X7_EM_PAXTON_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "EM Paxton ");
break;
*/
*/
case T55X7_FDXB_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "FDXB ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "FDXB ");
break;
case T55X7_HID_26_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "HID 26b ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "HID 26b ");
break;
case T55X7_PYRAMID_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Pyramid ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Pyramid ");
break;
case T55X7_INDALA_64_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Indala 64");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 64");
break;
case T55X7_INDALA_224_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Indala 224 ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 224 ");
break;
case T55X7_GUARDPROXII_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Guard Prox II ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Guard Prox II ");
break;
case T55X7_VIKING_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Viking ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Viking ");
break;
case T55X7_NORALYS_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Noralys ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Noralys ");
break;
case T55X7_IOPROX_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "IO Prox ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "IO Prox ");
break;
case T55X7_PRESCO_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Presco ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Presco ");
break;
case T55X7_NEDAP_64_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Nedap 64 ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Nedap 64 ");
break;
case T55X7_NEDAP_128_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "Nedap 128 ");
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Nedap 128 ");
break;
default:
break;
default: break;
}
if ( strlen(s) > 0 ) {
if (strlen(s) > 0) {
PrintAndLogEx(NORMAL, " Known T55x7 Config block found : " _YELLOW_("%s"), s);
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
}
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
}
}
int CmdT55xxInfo(const char *Cmd) {

View file

@ -301,9 +301,9 @@ int main(int argc, char *argv[]) {
// set baudrate
if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-baud") == 0) {
uint32_t tmpspeed = strtoul(argv[i+1], NULL, 10);
uint32_t tmpspeed = strtoul(argv[i + 1], NULL, 10);
if ((tmpspeed == ULONG_MAX) || (tmpspeed == 0)) {
PrintAndLogEx(WARNING, "ERROR: invalid baudrate: %s %s\n", argv[i], argv[i+1]);
PrintAndLogEx(WARNING, "ERROR: invalid baudrate: %s %s\n", argv[i], argv[i + 1]);
return 1;
}
speed = tmpspeed;

View file

@ -37,9 +37,9 @@ bool reply_via_fpc = 0;
extern void Dbprintf(const char *fmt, ...);
#define Dbprintf_usb(...) {\
reply_via_fpc = 0;\
Dbprintf(__VA_ARGS__);\
reply_via_fpc = 1;}
reply_via_fpc = 0;\
Dbprintf(__VA_ARGS__);\
reply_via_fpc = 1;}
#endif
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
@ -67,7 +67,7 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
#ifdef WITH_FPC_HOST
if (reply_via_fpc) {
sendlen = usart_writebuffer( (uint8_t*)&txcmd, sizeof(UsbCommand) );
sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommand));
Dbprintf_usb("Sent %i bytes over usart", len);
} else {
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));

View file

@ -83,7 +83,7 @@ inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
pUS1->US_TPR = (uint32_t)us_outbuf;
pUS1->US_TCR = len;
pUS1->US_PTCR = AT91C_PDC_TXTEN;
while(!(pUS1->US_CSR & AT91C_US_ENDTX)) {};
while (!(pUS1->US_CSR & AT91C_US_ENDTX)) {};
pUS1->US_PTCR = AT91C_PDC_TXTDIS;
return len;
} else {

View file

@ -36,8 +36,8 @@ typedef struct {
} PACKED UsbCommand;
#ifdef WITH_FPC_HOST
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
extern bool reply_via_fpc;
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
extern bool reply_via_fpc;
#endif
// A struct used to send sample-configs over USB