doc.lua 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. sys.taskInit(
  2. -- can定时清中断.
  3. function()
  4. sys.waitUntil("SPI_INIT_OK")
  5. while true do
  6. -- testSpiFlash.sampleCan()
  7. -- testSpiFlash.interrupFlagClear()
  8. sys.wait(1000)
  9. end
  10. end
  11. )
  12. sys.taskInit(
  13. -- can定时清中断.
  14. function()
  15. sys.wait(5000)
  16. testSpiFlash.init_my()
  17. sys.waitUntil("SPI_INIT_OK")
  18. while true do
  19. -- testSpiFlash.sampleCan()
  20. local canbuf = {0x01, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07}
  21. --18 FF 26 32
  22. testSpiFlash.Period_CAN_Send(0x18FF2631, canbuf) --0xF001
  23. sys.wait(1000)
  24. end
  25. end
  26. )
  27. sys.taskInit(
  28. function()
  29. local uploadTimePeriod = 5000
  30. local timerCount = 0
  31. local extdCanEnbale = true
  32. sys.waitUntil("SPI_INIT_OK")
  33. --while true do
  34. --local uptable = {}
  35. -- local table = _G.canTable
  36. --if next(table) ~= nil and next(table) ~= "" then
  37. --for k, v in pairs(table) do
  38. -- log.info("table data list is", k:toHex(), v:toHex())
  39. --local nextpos, canid, candata
  40. --canid, candata = k, v
  41. --nextpos, canid = pack.unpack(canid, ">I")
  42. --canid = testSpiFlash.reg2canid(canid, extdCanEnbale)
  43. --log.info("receive can id is", string.format("%08X", canid))
  44. --local canidStr = string.format("%08X", canid)
  45. --uptable[canidStr] = v:toHex() --放入到上报table中
  46. --table[k] = nil --清空当前键值.
  47. --end
  48. --end
  49. -- log.info("can frame is receied", result, list)
  50. -- if next(uptable) ~= nil then
  51. --local str = json.encode(uptable)
  52. -- str = create.LuaReomve(str, "\\")
  53. -- log.info("upload json data is", str)
  54. --sys.publish("NET_SENT_RDY_" .. "1", str)
  55. --end
  56. --[[ local table
  57. for k, v in pairs(uploadJson) do
  58. -- log.info("data is", k, v)
  59. if next(v) ~= nil then
  60. table = v
  61. local str = json.encode(table)
  62. str = create.LuaReomve(str, "\\")
  63. log.info("upload json data is", str)
  64. sys.publish("NET_SENT_RDY_" .. "1", str)
  65. -- 上传监控服务器时间间隔
  66. if timerCount == 0 then
  67. sys.publish("NET_SENT_RDY_" .. "3", str)
  68. end
  69. -- json格式拆包发送时间间隔.
  70. sys.wait(1000)
  71. log.info("not nil value", k, v)
  72. end
  73. end ]]
  74. log.info("upload task is running")
  75. sys.wait(uploadTimePeriod)
  76. timerCount = timerCount + 1
  77. timerCount = math.fmod(timerCount, 5)
  78. --end
  79. end
  80. )