Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. if(RxStart!=RxStop)
  2. {
  3. while((RxStop>=RxStart)&&(RxStop-RxStart>=X+4))
  4. {
  5. if(RxBuff[RxStart & 0xFF]==0xAA && RxBuff[(RxStart+X) & 0xFF]==0xCC &&
  6. RxBuff[(RxStart+X+1) & 0xFF]==0x33 && RxBuff[(RxStart+X+2) & 0xFF]==0xC3
  7. && RxBuff[(RxStart+X+3) & 0xFF]==0x3C)
  8. {
  9. if(CheckSum==OK)
  10. {
  11. switch(RxBuff[RxStart+1 & 0xFF])
  12. {
  13.  
  14. }
  15. }
  16. }
  17. }
  18. }
  19.  
  20. publish("someTopic","someMessage")
  21.  
  22. publish_f32("foo",1.23e-4)
  23. publish_u32("bar",56789)
  24.  
  25. // Add an indexing meaning to the topic
  26. publish("foo:1",45) // foo with index = 1
  27. publish("foo:2",56) // foo with index = 2
  28.  
  29. // Add a grouping meaning to the topic
  30. publish("bar/foo",67) // foo is under group 'bar'
  31.  
  32. // Combine
  33. publish("bar/foo:45",54)
  34.  
  35. // your device's uart library function signatures (usually you already have them)
  36. int32_t read(void * buf, uint32_t sizeToRead);
  37. int32_t readable();
  38. int32_t write(void * buf, uint32_t sizeToWrite);
  39. int32_t writeable();
  40.  
  41. // At the beginning of main function, this is the ONLY code you have to add to support a new device with telemetry
  42. TM_transport transport;
  43. transport.read = read;
  44. transport.write = write;
  45. transport.readable = readable;
  46. transport.writeable = writeable;
  47.  
  48. // Init telemetry with the transport structure
  49. init_telemetry(&transport);
  50.  
  51. // and you're good to start publishing
  52. publish_i32("foobar",...
  53.  
  54. import runner
  55. import pytelemetry.pytelemetry as tm
  56. import pytelemetry.transports.serialtransport as transports
  57. import time
  58.  
  59. transport = transports.SerialTransport()
  60. telemetry = tm.pytelemetry(transport)
  61. app = runner.Runner(transport,telemetry)
  62.  
  63. def printer(topic, data):
  64. print(topic," : ", data)
  65.  
  66. options = dict()
  67. options['port'] = "COM20"
  68. options['baudrate'] = 9600
  69.  
  70. app.connect(options)
  71.  
  72. telemetry.subscribe(None, printer)
  73. telemetry.publish('bar',1354,'int32')
  74. time.sleep(3)
  75.  
  76. app.terminate()
  77.  
  78. pytlm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement