It seems that I have used a modified version of Evok 1.0.2
My apigpio.py contains the following class:
class SerialBus(_PigBus):
def __init__(self, circuit=1,
host=os.getenv("PIGPIO_ADDR", ''),
port=os.getenv("PIGPIO_PORT", 8888),
uart_port="",
uart_baudr=0
):
super(SerialBus, self).__init__(circuit, host, port)
# _PigBus.__init__(self, circuit, host, port)
self.uart_port = uart_port
self.uart_baudr=uart_baudr
def full(self):
return {'dev': 'serialbus', 'circuit': self.circuit, 'uart_port': self.uart_port, 'uart_baudr': self.uart_baudr}
And in the unipi.py
class P1(object):
"""
P1 to Serial
"""
def __init__(self, serialbus, circuit):
self.circuit=circuit
self.serialbus = serialbus
print("Opening serialbus: ", serialbus.uart_port)
self.uart= serialbus.serial_open(serialbus.uart_port, serialbus.uart_baudr)
atexit.register(self.stop)
def stop(self):
self.serialbus.serial_close(self.uart)
def full(self):
return {'dev': 'P1', 'circuit':self.circuit, 'value':self.data}
@gen.coroutine
def read_loop(self, mainloop):
print("Entering read loop")
#mainloop = IOLoop.instance()
self.completedata=""
try:
while True:
if (self.read()):
yield gen.Task(mainloop.call_later, 5)
except Exception, E:
print("%s" % str(E))
@gen.coroutine
def read(self):
with (yield self.serialbus.iolock.acquire()):
rdy=yield self.serialbus.apigpio_command(pigpio. _PI_CMD_SERDA, self.uart,0)
if (rdy > 0):
# print("Bytes ready: ") + str(rdy)
with (yield self.serialbus.iolock.acquire()):
bytes = pigpio.u2i((yield self.serialbus.apigpio_command(pigpio._PI_CMD_SERR, self.uart, rdy)))
if bytes > 0:
databytes= yield self.serialbus.arxbuf(bytes)
self.completedata= self.completedata+str(databytes)
if "!" in databytes:
self.data=self.completedata
devents.status(self)
self.completedata=""
return
raise gen.Return(True)
But since it is not original to Evok I probably have to figure this out on my own..