Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------------------------------------------------------
- void NavisInitProcedure()
- {
- int crc, len;
- char o;
- char needsCrc;
- char buf[10];
- struct timeval t;
- t.tv_sec =0;
- t.tv_usec = 250E+3;
- if (!TimerPast (navis.initTimer, t))
- return;
- GetCurrentTime(&navis.initTimer);
- len=1; // default value
- needsCrc=1;// default value
- //10 17 01 10 03 -= example of requesting 0x17 message with 1 hz
- switch(navis.initStage)
- {
- // x- request, o - response
- case 0:
- buf[0]=0xb2;
- o=0xC2;
- buf[1]=2+4; // CRC enable, geodetic coords, height above ellipsoid
- buf[2]=0; //
- len=2;
- needsCrc=0;
- break;
- case 1:
- buf[0]=0x17;
- o=0x42; // requests for 0x42 message
- buf[1]=1;
- break;
- case 2:
- buf[0]=0x24;
- o=0x52; // requests for 0x52 message
- buf[1]=1;
- break;
- case 3:
- buf[0]=0xf4;
- o=0x70; // response: 0x70, 0x4A, 0x4B, 0xF5, 0xF6, 0xF7 with different intervals
- buf[1]=10; // частоты выдачи задается в 100 милисек интервалах
- break;
- case 4:
- buf[0]=0x27;
- o=0x88; // response: 0x88
- buf[1]=1; //
- break;
- case 5:
- buf[0]=0x0b;
- o=0x50;
- buf[1]=1;
- break;
- /* not using
- case 6:
- {
- x=0x2b;
- o=0x4b; // response: 0x4b
- byte1=10; //
- break;
- */
- default:
- navis.initStage=-1;
- printf ("Navis initialize finished\n");
- return;
- } //^^^ switch
- printf("initializing Navis, stage:%d, sending msg: 0x%02X and waiting for: 0x%02X...\n", navis.initStage, buf[0], o);
- navis.initStage++;
- GpsWrite(0x10);
- crc=0;
- for (int j=0; j<=len; j++)
- {
- GpsWrite(buf[j]);
- crc=UpdCrc(crc, buf[j]);
- }
- if (needsCrc)
- {
- GpsWrite(0x10);
- GpsWrite(0xFF);
- GpsWrite(crc & 0xFF);
- GpsWrite((crc >> 8) & 0xFF);
- }
- GpsWrite(0x10);
- GpsWrite(0x03);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement