I am working on integrating a fourth uBlox binary UBX message (TIMEUTC) for date and time logging into the ArduIMU.
The problem is (i believe) that the total of all four messages counts to 132 bytes. The arduino's serial buffer can only do 128 so I am dropping the last four bytes which ends up throwing off the minutes and seconds and last checksums. Unfortunately I cannot adjust the messages coming out of the uBlox (i would love to create a custom message) :(.
Does anyone know a better way to read the serial buffer in order to get additional message support??
The ArduIMU code snippet is here
void decode_gps(void)
{
static unsigned long GPS_timer=0;
byte data;
int numc;
numc = Serial.available();
if (numc > 0)
for (int i=0; i<numc; i++) // Process bytes received
{
data = Serial.read();
switch(UBX_step) //Normally we start from zero. This is a state machine
{
case 0:
if(data==0xB5) // UBX sync char 1
UBX_step++; //OH first data packet is correct, so jump to the next step
break;
case 1:
if(data==0x62) // UBX sync char 2
UBX_step++; //ooh! The second data packet is correct, jump to the step 2
else
UBX_step=0; //Nope, its not correct so go to step zero and try again.
break;
case 2:
UBX_class=data;
checksum(UBX_class);
UBX_step++;
break;
case 3:
UBX_id=data;
checksum(UBX_id);
UBX_step++;
break;
case 4:
UBX_payload_length_hi=data;
checksum(UBX_payload_length_hi);
UBX_step++;
break;
case 5:
UBX_payload_length_lo=data;
checksum(UBX_payload_length_lo);
UBX_step++;
break;
case 6: // Payload data read...
if (UBX_payload_counter < UBX_payload_length_hi) // We stay in this state until we reach the payload_length
{
UBX_buffer[UBX_payload_counter] = data;
checksum(data);
UBX_payload_counter++;
}
else
UBX_step++;
break;
case 7:
UBX_ck_a=data; // First checksum byte
UBX_step++;
break;
case 8:
UBX_ck_b=data; // Second checksum byte
// We end the GPS read...
if((ck_a=UBX_ck_a)&&(ck_b=UBX_ck_a)) // Verify the received checksum with the generated checksum..
parse_ubx_gps(); // Parse new GPS packet...
for (int q=0;q<41;q++)
{
UBX_buffer[q] = 0;
}
UBX_step=0;
UBX_payload_counter=0;
ck_a=0;
ck_b=0;
GPS_timer=millis(); //Restarting timer...
break;
} // End Switch
} // End For
}
Thank You!