OPS MID 129 routine (switch from OPS to NMEA) for ISM420-480 EVB

News Article Feature Image

Function: OSPMID129

Description: Send SiRF MID 129 (Switch to NMEA Protocol) to GPS in OSP mode


// where: A0A20018 - Start sequence/Payload length
// 81020101000101010501010100010001001000012580 - Payload
// 01ABB0B3 - Checksum/End sequence
// 81 MID
// 02 Mode: 00-Enable NMEA debug msg
// 01-Disable NMEA debug msg
// 02-Don't change last set value
// 01 GGA message rate (sec)
// 01 Checksum GGA message
// 00 GLL message rate (sec)
// 01 Checksum GLL message
// 01 GSA message rate (sec)
// 01 Checksum GSA message
// 05 GSV message rate (sec)
// 01 Checksum GGA message
// 01 RMC message rate (sec)
// 01 Checksum RMC message
// 00 VTG message rate (sec)
// 01 Checksum VTG message
// 00 MSS message rate (sec)
// 01 Checksum MSS message
// 00 EPE message rate (sec)
// 01 Checksum EPE message
// 00 ZDA message rate (sec)
// 01 Checksum ZDA message
// 00 Unused
// 00 Unused
// 2580 Bit rate 0480=1200, 0960=2400, 12C0=4800, 2580=9600,
// 4B00=19200, 9600=38400, E100=57600
//
void OSPMID129(char mode[], char GGA[], char GLL[], char GSA[], char GSV[],
char RMC[], char VTG[], char MSS[], char EPE[], char ZDA[],
char rate[])
{
char msg[65] = "A0A2001881"; // OSP msg start
char bmsg[32];
char csum[6];
char tmp[2];
unsigned int checksum = 0;
int i;
int j = 0;
strcat(msg,mode); // Add mode
strcat(msg,GGA); // Rate/CS
strcat(msg,GLL); // Rate/CS
strcat(msg,GSA); // Rate/CS
strcat(msg,GSV); // Rate/CS
strcat(msg,RMC); // Rate/CS
strcat(msg,VTG); // Rate/CS
strcat(msg,MSS); // Rate/CS
strcat(msg,EPE); // Rate/CS
strcat(msg,ZDA); // Rate/CS
strcat(msg,rate); // Add bit rate
strcat(msg,"0000"); // Add unused
for (i=8;i<strlen(msg);i+=2)
{
memcpy(&tmp,&msg[i],2);
checksum += axtoi(tmp); // Sum
checksum &= 0x7FFF;
}
sprintf(csum,"%04X",checksum); // Convert hex string
strcat(msg, csum); // Add checksum
strcat(msg,"B0B3"); // Add End sequence
strcat(msg, NULL); // Terminate
/* Convert to binary & send */
for (i=0;i<strlen(msg);i+=2)
{
memcpy(&tmp,&msg[i],2);
bmsg[j] = axtoi(tmp); // Convert & store
USART_SendChar(GPS_USART, bmsg[j]); // Send byte
j++;
}
DPRINT(msg); // Send to console
}