I have just started playing with Crossbar.io and love the concept. I have had no problems in creating 2 containers that communicate to each other via RPC and via publish/subscribe.
When I tried adding pyserial to the mix, things broke, and from what I gather, I would need to add a twisted serialPort implementation. With the code below, if I comment out the “self.esplora …” line, and the other container does an RPC to the pub method, all works.
If the self.esplora line is enabled, then the call to pub is never seen.
Here is my code for the container that manages the serial interface. :
import serial class EspSerial(ApplicationSession): def __init__(self, config): ApplicationSession.__init__(self, config) self.esplora = serial.Serial('/dev/ttyACM0', 57600, timeout=1) self.do_publish = False @inlineCallbacks def onJoin(self, details): print("esp_serial joined") def pub(pub_state): self.do_publish = pub_state print("esp_pub: ", pub_state) print('init done') reg = yield self.register(pub, 'com.app.pub') print("procedure pub() registered", reg)
is there some crossbar.io rookie error that I have committed, or am I correct in that I will need to use twisted serialPort?
Could I move the code above out to a guest and register a set of RPC’s for serial read and write and run “native” pyserial and avoid having to cope with Twisted’ serial implementation?