[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gpsd-commit-watch
Subject:    [Gpsd-commit-watch] r4016 - trunk
From:       garyemiller () mail ! berlios ! de
Date:       2006-11-29 2:28:12
Message-ID: 200611290228.kAT2SCR8014562 () sheep ! berlios ! de
[Download RAW message or body]

Author: garyemiller
Date: 2006-11-29 03:28:09 +0100 (Wed, 29 Nov 2006)
New Revision: 4016

Modified:
   trunk/garmin.c
Log:
Fix bad packet logging.  Delay the ACK a bit.

Modified: trunk/garmin.c
===================================================================
--- trunk/garmin.c	2006-11-29 00:06:36 UTC (rev 4015)
+++ trunk/garmin.c	2006-11-29 02:28:09 UTC (rev 4016)
@@ -639,6 +639,7 @@
        uint32_t layer_id UNUSED, uint32_t pkt_id, uint32_t length, uint32_t data ) 
 {
         uint8_t *buffer = (uint8_t *)session->driver.garmin.Buffer;
+        uint8_t *buffer0 = buffer;
 	Packet_t *thePacket = (Packet_t*)buffer;
 	ssize_t theBytesReturned = 0;
 	ssize_t theBytesToWrite = 6 + (ssize_t)length;
@@ -681,9 +682,9 @@
 		    , theBytesToWrite, gpsd_hexdump(thePacket, (size_t)theBytesToWrite));
 #endif
         (void)PrintSERPacket ( session,  
-			       (unsigned char)buffer[1], 
-			       (int)buffer[2], 
-			       (unsigned char *)(buffer + 3));
+			       (unsigned char)buffer0[1], 
+			       (int)buffer0[2], 
+			       (unsigned char *)(buffer0 + 3));
 
 	theBytesReturned = write( session->gpsdata.gps_fd
 				  , thePacket, (size_t)theBytesToWrite);
@@ -948,13 +949,15 @@
 	gpsd_report(LOG_RAW+1, "Char: %#02x\n", data_buf[i]);
     }
 
-    Send_ACK();
 
     gpsd_report(LOG_IO
 	, "garmin_ser_parse() Type: %#02x, Len: %#02x, chksum: %#02x\n"
         , pkt_id, pkt_len, chksum);
 
     mask = PrintSERPacket(session, pkt_id, pkt_len, data_buf);
+
+    // sending ACK too soon might fail, so do it last
+    Send_ACK();
     /*@ +usedef +compdef @*/
     return mask;
 }

_______________________________________________
Gpsd-commit-watch mailing list
Gpsd-commit-watch@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/gpsd-commit-watch
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic