Raspberry Pi Gateway not working on new install


  • Mod

    Today I installed a new raspberry pi. When trying to add a MySensors Raspberry Pi gateway on it, I ran into a few problems.
    This is the configure command I used:

    ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB42 --my-rf24-irq-pin=15
    

    The gateway starts cleanly:

    pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw
    Mar 01 21:47:42 INFO  Starting gateway...
    Mar 01 21:47:42 INFO  Protocol version - 2.3.1
    Mar 01 21:47:42 DEBUG Serial port /dev/ttyUSB42 (115200 baud) created
    Mar 01 21:47:42 DEBUG MCO:BGN:INIT GW,CP=RNNGL-Q-,REL=255,VER=2.3.1
    Mar 01 21:47:42 DEBUG TSF:LRT:OK
    Mar 01 21:47:42 DEBUG TSM:INIT
    Mar 01 21:47:42 DEBUG TSF:WUR:MS=0
    Mar 01 21:47:42 DEBUG TSM:INIT:TSP OK
    Mar 01 21:47:42 DEBUG TSM:INIT:GW MODE
    Mar 01 21:47:42 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
    Mar 01 21:47:42 DEBUG MCO:REG:NOT NEEDED
    Mar 01 21:47:42 DEBUG MCO:BGN:STP
    Mar 01 21:47:42 DEBUG MCO:BGN:INIT OK,TSP=1
    Mar 01 21:47:42 DEBUG TSM:READY:NWD REQ
    Mar 01 21:47:42 DEBUG TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    Mar 01 21:50:11 DEBUG TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:50.5
    
    1. The permissions on the device are set so that the group does not have read access (but group does have write access). Isn't that strange?
    pi@raspberrypi:~ $ ls -la /dev/ttyUSB42
    lrwxrwxrwx 1 root root 10 Mar  1 21:47 /dev/ttyUSB42 -> /dev/pts/1
    pi@raspberrypi:~ $ ls -la /dev/pts/1
    crw--w---- 1 root tty 136, 1 Mar  1 21:48 /dev/pts/1
    
    1. The log file (/tmp/mysgw.log) is not written to continuously. When I start the gateway (and it prints a lot of stuff to the console and to syslog since I also enabled that), nothing is printed to the log file. When I press ctrl+c to exit, the full log appears in the log file. Seems like the log isn't being flushed?

    2. I did a chmod g+r and chmod o+rw on /dev/pts/1 and added the gateway to Domoticz. Domoticz keeps saying

    2019-03-01 21:51:38.466 Status: MySensors: Using serial port: /dev/ttyUSB42
    2019-03-01 21:51:38.468 Error: Serial Port closed!... Error: End of file
    2019-03-01 21:51:39.468 Status: MySensors: retrying in 30 seconds...
    2019-03-01 21:52:08.473 Status: MySensors: Using serial port: /dev/ttyUSB42
    2019-03-01 21:52:08.474 Error: Serial Port closed!... Error: End of file
    2019-03-01 21:52:09.474 Status: MySensors: retrying in 30 seconds...
    2019-03-01 21:52:38.479 Status: MySensors: Using serial port: /dev/ttyUSB42
    2019-03-01 21:52:38.480 Error: Serial Port closed!... Error: End of file
    2019-03-01 21:52:39.480 Status: MySensors: retrying in 30 seconds...
    2019-03-01 21:53:08.485 Status: MySensors: Using serial port: /dev/ttyUSB42
    2019-03-01 21:53:08.487 Error: Serial Port closed!... Error: End of file
    

    When I do sudo cat /dev/ttyUSB42 I am immediately returned to the prompt (nothing is printed). If I remember correctly, cat should continuously print messages from the gateway.


  • Mod

    @mfalkvidd said in Raspberry Pi Gateway not working on new install:

    If I remember correctly, cat should continuously print messages from the gateway

    That would be the tail command. Cat dumps whatever is in there and returns on eof.
    Also, when dumping data from serial devices the baudrate etc should be set to match your gateway's settings, using e.g. the stty command.


  • Mod

    @yveaux yes you're right. I should have used tail -f

    The flushing problem (number 2 in the list above) is addressed in https://github.com/mysensors/MySensors/pull/1269

    mfalkvidd created this issue in mysensors/MySensors

    closed Rpi: flush log file #1269


  • Mod

    The mystery in question number 1 is solved. Unless --my-serial-groupname is specified in the configure command, permissions will not be set. By default, the group is tty, and the permissions are "w". By specifying --my-serial-groupname=tty I get the tty group, as default, but I also get "rw" permissions.

    The default behavior should probably be rw for the group, even without setting --my-serial-groupname. I'll see if I can do some digging to figure out why the default is strange.


  • Mod

    Although the default permissions are unexpected (at least to me), they are intentional. From: https://linux.die.net/man/3/grantpt

    The group ID is set to an unspecified value (e.g., tty). The mode of the slave is set to 0620 (crw--w----).


 

291
Online

8.9k
Users

9.7k
Topics

101.3k
Posts