]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/appmain.c
cleaning up uart_posix.c
[proxmark3-svn] / armsrc / appmain.c
index 6a3b6e8199e8339a4d3dec81c1a544e8d74b25de..2eb54d27449ef2838ed8e9e93505bd2450b39896 100644 (file)
@@ -13,7 +13,6 @@
 #include <stdarg.h>
 
 #include "usb_cdc.h"
-#include "cmd.h"
 #include "proxmark3.h"
 #include "apps.h"
 #include "fpga.h"
@@ -347,7 +346,7 @@ void SendVersion(void) {
        // Send Chip ID and used flash memory
        uint32_t text_and_rodata_section_size = (uint32_t)&__data_src_start__ - (uint32_t)&_flash_start;
        uint32_t compressed_data_section_size = common_area.arg1;
-       cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, hw_capabilities, VersionString, strlen(VersionString));
+       cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, hw_capabilities, VersionString, strlen(VersionString) + 1);
 }
 
 // measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
@@ -936,9 +935,7 @@ void ListenReaderField(int limit) {
 }
 
 
-void UsbPacketReceived(uint8_t *packet, int len) {
-
-       UsbCommand *c = (UsbCommand *)packet;
+void UsbPacketReceived(UsbCommand *c) {
 
 //  Dbprintf("received %d bytes, with command: 0x%04x and args: %d %d %d",len,c->cmd,c->arg[0],c->arg[1],c->arg[2]);
 
@@ -1428,7 +1425,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
                case CMD_DEVICE_INFO: {
                        uint32_t dev_info = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS;
                        if(common_area.flags.bootrom_present) dev_info |= DEVICE_INFO_FLAG_BOOTROM_PRESENT;
-                       cmd_send(CMD_DEVICE_INFO,dev_info,0,0,0,0);
+                       cmd_send_old(CMD_DEVICE_INFO,dev_info,0,0,0,0);
                        break;
                }
                default:
@@ -1479,29 +1476,21 @@ void  __attribute__((noreturn)) AppMain(void) {
        LCDInit();
 #endif
 
-       uint8_t rx[sizeof(UsbCommand)];
-       size_t rx_len;
-
+       UsbCommand rx;
+  
        for(;;) {
-               if (usb_poll()) {
-                       rx_len = usb_read(rx, sizeof(UsbCommand));
-                       if (rx_len) {
-                               UsbPacketReceived(rx, rx_len);
-                       }
-               }
                WDT_HIT();
-
-#ifdef WITH_LF_StandAlone
-#ifndef WITH_ISO14443a_StandAlone
-               if (BUTTON_HELD(1000) > 0)
-                       SamyRun();
-#endif
-#endif
-#ifdef WITH_ISO14443a
-#ifdef WITH_ISO14443a_StandAlone
-               if (BUTTON_HELD(1000) > 0)
-                       StandAloneMode14a();
+               if (cmd_receive(&rx)) {
+                       UsbPacketReceived(&rx);
+               } else {
+#if defined(WITH_LF_StandAlone) && !defined(WITH_ISO14443a_StandAlone)
+                       if (BUTTON_HELD(1000) > 0)
+                               SamyRun();
 #endif
+#if defined(WITH_ISO14443a) && defined(WITH_ISO14443a_StandAlone)
+                       if (BUTTON_HELD(1000) > 0)
+                               StandAloneMode14a();
 #endif
+               }
        }
 }
Impressum, Datenschutz