-void SendCommand(UsbCommand* txcmd) {
-// printf("send: ");
-// cmd_debug(txcmd);
- if (!uart_send(sp,(byte_t*)txcmd,sizeof(UsbCommand))) {
- printf("Sending bytes to proxmark failed\n");
- exit(1);
- }
-}
-
-void ReceiveCommand(UsbCommand* rxcmd) {
- byte_t* prxcmd = (byte_t*)rxcmd;
- byte_t* prx = prxcmd;
- size_t rxlen;
- while (true) {
- rxlen = sizeof(UsbCommand) - (prx-prxcmd);
- if (uart_receive(sp,prx,&rxlen)) {
-// printf("received [%zd] bytes\n",rxlen);
- prx += rxlen;
- if ((prx-prxcmd) >= sizeof(UsbCommand)) {
-// printf("received: ");
-// cmd_debug(rxcmd);
- return;
- }
- }
- }
-}
-
-void CloseProxmark() {
- // Clean up the port
- uart_close(sp);
- // Fix for linux, it seems that it is extremely slow to release the serial port file descriptor /dev/*
- unlink(serial_port_name);
-}
-
-int OpenProxmark(size_t i) {
- sp = uart_open(serial_port_name);
- if (sp == INVALID_SERIAL_PORT) {
- //poll once a second
- msleep(100);
- return 0;
- }
- return 1;
-}
-