Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(RxStart!=RxStop)
- {
- while((RxStop>=RxStart)&&(RxStop-RxStart>=X+4))
- {
- if(RxBuff[RxStart & 0xFF]==0xAA && RxBuff[(RxStart+X) & 0xFF]==0xCC &&
- RxBuff[(RxStart+X+1) & 0xFF]==0x33 && RxBuff[(RxStart+X+2) & 0xFF]==0xC3
- && RxBuff[(RxStart+X+3) & 0xFF]==0x3C)
- {
- if(CheckSum==OK)
- {
- switch(RxBuff[RxStart+1 & 0xFF])
- {
- }
- }
- }
- }
- }
- publish("someTopic","someMessage")
- publish_f32("foo",1.23e-4)
- publish_u32("bar",56789)
- // Add an indexing meaning to the topic
- publish("foo:1",45) // foo with index = 1
- publish("foo:2",56) // foo with index = 2
- // Add a grouping meaning to the topic
- publish("bar/foo",67) // foo is under group 'bar'
- // Combine
- publish("bar/foo:45",54)
- // your device's uart library function signatures (usually you already have them)
- int32_t read(void * buf, uint32_t sizeToRead);
- int32_t readable();
- int32_t write(void * buf, uint32_t sizeToWrite);
- int32_t writeable();
- // At the beginning of main function, this is the ONLY code you have to add to support a new device with telemetry
- TM_transport transport;
- transport.read = read;
- transport.write = write;
- transport.readable = readable;
- transport.writeable = writeable;
- // Init telemetry with the transport structure
- init_telemetry(&transport);
- // and you're good to start publishing
- publish_i32("foobar",...
- import runner
- import pytelemetry.pytelemetry as tm
- import pytelemetry.transports.serialtransport as transports
- import time
- transport = transports.SerialTransport()
- telemetry = tm.pytelemetry(transport)
- app = runner.Runner(transport,telemetry)
- def printer(topic, data):
- print(topic," : ", data)
- options = dict()
- options['port'] = "COM20"
- options['baudrate'] = 9600
- app.connect(options)
- telemetry.subscribe(None, printer)
- telemetry.publish('bar',1354,'int32')
- time.sleep(3)
- app.terminate()
- pytlm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement