Unipi 1.1 Evok 1.0.1 to 2.0.7 no UART



  • I have upgraded my Evok 1.0.1 to 2.0.7 on my Unipi 1.1. Now I am missing the UART interface in EVOK. What happend to it? And can I get it back?


  • administrators

    @jcmschoot what UART device? Do you have some RS485 usb converter?



  • Sorry for the late reply.

    The UART port on the Unipi 1.1. I have connected it to an digital "smart" electricity meter we use. The digital meter produces messages in P1 format on it's RS232 port which is connected to the UART port on the Unipi 1.1.
    This all worked fine in Evok 1.0.1. but in Evok 2.0.7 the UART port cannot be addressed..

    I made slight changes to the Evok 1.0.1 so the UART input/ P1 messages will be send in the websocket connection. I tried to copy and change this to Evok 2.0.7 but I am missing parts to connect to the UART port.

    I have tested if it is possible using the unipig libraries of Unipi 2.0.7 in a separate python app and that works.


  • administrators

    Hello,
    Evok should not affect the UART on Unipi 1.1 in any way. Please note that bluetooth interface shares the same pins (GPIOs) on Raspberry Pi 3. For use these pins as the UART, just add dtoverlay=pi3-disable-bt to /boot/config.txt file on your Raspberry Pi 3.



  • @martin_triska The UART it self works, I have tested that on the PI with an serial console test and also with the unipig library in a python test app. But the UART device implementation is not in the EVOK 2.0.7 anymore.


  • administrators

    It seems there is a misunderstanding. Can you exactly reference the functionality you currently lack (file/line in the Evok 1.0.1 source code) ?



  • 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..


  • administrators

    Yes, it is clear now. You have to implement this kind of functionality by yourself as Evok does not offer it.