main.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. PROJECT = "ADC"
  2. VERSION = "2.0.0"
  3. --加载日志功能模块,并且设置日志输出等级
  4. --如果关闭调用log模块接口输出的日志,等级设置为log.LOG_SILENT即可
  5. require "log"
  6. LOG_LEVEL = log.LOGLEVEL_TRACE
  7. require "sys"
  8. require "gps"
  9. rtos.on(rtos.MSG_RTK_INFO, function(msg)
  10. log.info("rtk",msg.id,msg.status,msg.data)
  11. end)
  12. local function nmeaCb(nmeaItem)
  13. -- log.info("rtk nmeaCb",nmeaItem)
  14. rtk.write(nmeaItem)
  15. end
  16. local function test()
  17. sys.wait(5000)
  18. --1 02-15 RXM-RAWX 16
  19. local cmd10 = string.char(0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x02, 0x15, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x28, 0x4E)
  20. --115200
  21. local cmd13 = string.char(0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0xC2, 0x01, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7E)
  22. --GPS+BD+QZSS
  23. local cmd15 = string.char(0xB5, 0x62, 0x06, 0x3E, 0x3C, 0x00, 0x00, 0x00, 0x20, 0x07, 0x00, 0x08, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x08, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x01, 0x05, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x01, 0x06, 0x08, 0x0E, 0x00, 0x00, 0x00, 0x01, 0x01, 0x2E, 0x75)
  24. --NAV_PVT
  25. local cmd21 = string.char(0xB5, 0x62, 0x06, 0x01, 0x03, 0x00, 0x01, 0x07, 0x01, 0x13, 0x51)
  26. --PPS
  27. local cmd23 = string.char(0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x40, 0x42, 0x0F, 0x00, 0x40, 0x42, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x00, 0x00, 0x00, 0xCA, 0xB6)
  28. --5HZ
  29. local cmd24 = string.char(0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00, 0xDE, 0x6A)
  30. --sub-frame
  31. local cmd25 = string.char(0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x02, 0x13, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x25, 0x3d)
  32. uart.setup(1,9600,8,uart.PAR_NONE,uart.STOP_1)
  33. sys.wait(100)
  34. uart.write(1, cmd10)
  35. sys.wait(100)
  36. uart.write(1, cmd15)
  37. sys.wait(100)
  38. uart.write(1, cmd25)
  39. sys.wait(100)
  40. uart.write(1, cmd21)
  41. sys.wait(100)
  42. uart.write(1, cmd23)
  43. sys.wait(100)
  44. uart.write(1, cmd13)
  45. sys.wait(100)
  46. uart.close(1)
  47. gps.setUart(1,115200,8,uart.PAR_NONE,uart.STOP_1)
  48. gps.setNmeaMode(2,nmeaCb)
  49. gps.open(gps.DEFAULT,{tag="rtk"})
  50. local para =
  51. {
  52. appKey = "A48k297jhqeo",
  53. appSecret = "956f15a90a318e34",
  54. solMode = rtk.SOLMODE_RTK,
  55. solSec = rtk.SEC_5S,
  56. reqSec = rtk.SEC_5S
  57. }
  58. rtk.open(para);
  59. -- sys.wait(20000);
  60. -- rtk.close()
  61. -- para.reqFre = rtk.FRE_1S
  62. -- sys.wait(1000);
  63. -- rtk.open(para);
  64. end
  65. sys.taskInit(test)
  66. --启动系统框架
  67. sys.init(0, 0)
  68. sys.run()