SIRF binary protocol

beowulf發表於2007-07-30

寫點東西吧,說不定別人有用,sirfIII的晶片,兩種指令和資料模式

NEMA

Sirf Binary

[@more@]

當你執行了NEMA的轉化為sirf格式的指令後,如果用超級終端類的工具會無比鬱悶

恢復為nema的指令如下

A0A20018810201010001010105010101000100010001000100012580013AB0B3

大量的0,字串裡0就是結束符,無論後面是什麼都不會再繼續執行下去了

指令的儲存也不要想偷懶,老老實實一個一個byte存吧

我的一段垃圾程式

byte tt[]={0xA0,0xA2,0x00,0x18, //----------------------/*head*/
0x81,0x02, //message id
0x01,0x01, // GGA output interval , has CheckSum?(1/0) (6,7)
0x00,0x01, // GLL (8,9)
0x01,0x01, //GSA (10,11)
0x05,0x01, //GSV
0x01,0x01, //RMC
0x00,0x01, //VTG
0x00,0x01, //MSS
0x00,0x01, //not defined
0x00,0x01, //ZDA
0x00,0x01, //not defined
0x25,0x80, // bitrate ----------- /*payload*/
0x01,0x3A,0xB0,0xB3 /*checksum and end sequence*/
};
unsigned long dwWrite;
int i;
Word checksum=0;
Word bitrate;
//binary protocol bitrate 為 NMEA->sirf binary 設定的波特率
ComboBox2->Text="COM3";
Edit3->Text="38400";
if(Button6->Enabled==true )Button6->Click();
Sleep(1000);
Button5->Click();

//引數設定
for(i=0;i<10;i++)
{
tt[6+2*i]=NMEAMESSAGE[i].interval;
tt[6+2*i+1]=NMEAMESSAGE[i].hasCheckSum;
}
//設定bitrate
bitrate=BR_COMM;
tt[26]=(byte)(bitrate>>8);
tt[27]=(byte)(bitrate&0x00ff);
//
for(i=4;i<28;i++)
{
checksum+=tt[i];
}
checksum&=0x7fff;
tt[28]=(byte)(checksum>>8);
tt[29]=(byte)(checksum&0x00ff);
WriteFile(hComm,&tt,32,&dwWrite,NULL);
this->Caption=IntToStr(dwWrite);
// this->Caption=IntToStr(checksum);

Edit3->Text=IntToStr(bitrate);
if(Button6->Enabled==true )Button6->Click();
Sleep(1000);
Button5->Click();

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7202070/viewspace-929448/,如需轉載,請註明出處,否則將追究法律責任。

相關文章