Advertisement
buletz

Untitled

Apr 16th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1.  
  2. //--------------------------------------------------------------------------------
  3. void NavisInitProcedure()
  4. {
  5. int crc, len;
  6. char o;
  7. char needsCrc;
  8. char buf[10];
  9.  
  10. struct timeval t;
  11. t.tv_sec =0;
  12. t.tv_usec = 250E+3;
  13. if (!TimerPast (navis.initTimer, t))
  14. return;
  15.  
  16. GetCurrentTime(&navis.initTimer);
  17.  
  18. len=1; // default value
  19. needsCrc=1;// default value
  20.  
  21. //10 17 01 10 03 -= example of requesting 0x17 message with 1 hz
  22.  
  23. switch(navis.initStage)
  24. {
  25. // x- request, o - response
  26. case 0:
  27. buf[0]=0xb2;
  28. o=0xC2;
  29. buf[1]=2+4; // CRC enable, geodetic coords, height above ellipsoid
  30. buf[2]=0; //
  31. len=2;
  32. needsCrc=0;
  33. break;
  34. case 1:
  35. buf[0]=0x17;
  36. o=0x42; // requests for 0x42 message
  37. buf[1]=1;
  38. break;
  39. case 2:
  40. buf[0]=0x24;
  41. o=0x52; // requests for 0x52 message
  42. buf[1]=1;
  43. break;
  44. case 3:
  45. buf[0]=0xf4;
  46. o=0x70; // response: 0x70, 0x4A, 0x4B, 0xF5, 0xF6, 0xF7 with different intervals
  47. buf[1]=10; // частоты выдачи задается в 100 милисек интервалах
  48. break;
  49. case 4:
  50. buf[0]=0x27;
  51. o=0x88; // response: 0x88
  52. buf[1]=1; //
  53. break;
  54. case 5:
  55. buf[0]=0x0b;
  56. o=0x50;
  57. buf[1]=1;
  58. break;
  59. /* not using
  60. case 6:
  61. {
  62. x=0x2b;
  63. o=0x4b; // response: 0x4b
  64. byte1=10; //
  65. break;
  66. */
  67. default:
  68. navis.initStage=-1;
  69. printf ("Navis initialize finished\n");
  70. return;
  71. } //^^^ switch
  72.  
  73. printf("initializing Navis, stage:%d, sending msg: 0x%02X and waiting for: 0x%02X...\n", navis.initStage, buf[0], o);
  74. navis.initStage++;
  75.  
  76. GpsWrite(0x10);
  77. crc=0;
  78. for (int j=0; j<=len; j++)
  79. {
  80. GpsWrite(buf[j]);
  81. crc=UpdCrc(crc, buf[j]);
  82. }
  83. if (needsCrc)
  84. {
  85. GpsWrite(0x10);
  86. GpsWrite(0xFF);
  87. GpsWrite(crc & 0xFF);
  88. GpsWrite((crc >> 8) & 0xFF);
  89. }
  90.  
  91. GpsWrite(0x10);
  92. GpsWrite(0x03);
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement