PUD: move getting transmitGpsInformation fields to just before they're used
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 6 Mar 2012 14:34:38 +0000 (15:34 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Mar 2012 13:28:43 +0000 (14:28 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c

index baf3a36..95eb7cd 100644 (file)
@@ -729,12 +729,6 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
                return true;
        }
 
-       (void) pthread_mutex_lock(&transmitGpsInformation.mutex);
-       txPosition = transmitGpsInformation.txPosition;
-       txGateway = transmitGpsInformation.txGateway;
-       bestGateway = transmitGpsInformation.bestGateway;
-       (void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
-
        /* parse all NMEA strings in the rxBuffer into the incoming entry */
        incomingEntry = getPositionAverageEntry(&positionAverageList, INCOMING);
        nmea_zero_INFO(&incomingEntry->nmeaInfo);
@@ -782,6 +776,12 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
         * Movement detection
         */
 
+       (void) pthread_mutex_lock(&transmitGpsInformation.mutex);
+       txPosition = transmitGpsInformation.txPosition;
+       txGateway = transmitGpsInformation.txGateway;
+       bestGateway = transmitGpsInformation.bestGateway;
+       (void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
+
        clearMovementType(&movementResult);
        detemineMovingFromGateway(&bestGateway, &txGateway, &movementResult);
        if (movementResult.moving != SET) {