]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/uart.c
hitag2 write (#310)
[proxmark3-svn] / client / uart.c
index 041186c7e9d195b817766dba7e1b80adffe2117c..4b2fee994f533d0044c729f36ce01690c113a8aa 100644 (file)
@@ -73,6 +73,7 @@ serial_port uart_open(const char* pcPortName)
   // Does the system allows us to place a lock on this file descriptor
   if (fcntl(sp->fd, F_SETLK, &fl) == -1) {
     // A conflicting lock is held by another process
+    free(sp);
     return CLAIMED_SERIAL_PORT;
   }
 
@@ -266,7 +267,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) {
     if (res < 0) {
       return false;
     }
-    
     // Read time-out
     if (res == 0) {
       if (*pszRxLen == 0) {
@@ -277,21 +278,24 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen) {
         return true;
       }
     }
-    
     // Retrieve the count of the incoming bytes
     res = ioctl(((serial_port_unix*)sp)->fd, FIONREAD, &byteCount);
     if (res < 0) return false;
-    
+
     // There is something available, read the data
     res = read(((serial_port_unix*)sp)->fd,pbtRx+(*pszRxLen),byteCount);
-    
+
     // Stop if the OS has some troubles reading the data
     if (res <= 0) return false;
-    
     *pszRxLen += res;
+
+    if(res==byteCount)
+        return true;
     
   } while (byteCount);
-  
+
   return true;
 }
 
Impressum, Datenschutz