PiGatewaySerial is stopped responding during catching new sensors



  • Hi all,

    I try to use the PiGatewaySerial on a new raspberyy pi 2. After some modifiactions on the code concering the differnet addressing and gpio Pins it starts up and logs incoming datagrams on the console.
    That works fine until a Client was switched on and sends his capabilities.

    here ist the Output before the PiGatewaySerial stoppes responding:

    0;0;3;0;9;read: 10-10-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
    0;0;3;0;9;read: 10-10-0 s=255,c=3,t=6,pt=1,l=1:0
    0;0;3;0;9;send: 0-0-10-10 s=255,c=3,t=6,pt=0,l=2,st=ok:M

    0;0;3;0;9;read: 10-10-0 s=255,c=3,t=11,pt=0,l=15:Pressure Sensor
    0;0;3;0;9;read: 10-10-0 s=255,c=3,t=12,pt=0,l=3:1.0

    The control I would like to is fhem on the same PI connecting over the pseudo Serial port.

    Any idea what happens and how to fix?

    Andreas


  • Code Contributor

    I will test in raspberry pi 1 I have here and try to figure out what's going on.



  • The cause for the stop is the lenght of the sketchname "Pressure Sensor". It is stored in the same memory area where the childNodeTable holds its data, So the
    "if (childNodeTable[childId] != route) {" in MySensor::addChildRoute brings up an Segmentation fault.

    For my point of view the following is wrong in MySensor,h:

    287 #ifdef DEBUG
    288 char convBuf[MAX_PAYLOAD];
    289 #endif

    it should be
    287 #ifdef DEBUG
    288 char convBuf[MAX_PAYLOAD*2+1];
    289 #endif

    because in MyGateway.h it is defined the same
    Line 58: char convBuf[MAX_PAYLOAD*2+1];

    if you look in the Arduino MySensor,.h ist is defined the same as in MyGateway,h

    That would explain the memory overrun and that it work for some people because the dont define debug!

    I have changed this lines and it became much more stable. But after only one day of testing I would not leave the Patient out off Hospital.

    Just my two cent with very limited cpp knowledge.

    Andreas



  • Just on more comment on your code.

    The pseudo TTY Port you create in PiGatewaySerial with openpty creates and port with the Default rights RWX for the User and W for the tty group.
    That leaves it unusable for other users than root. Even members of the tty Group are limited to write. Very usefull for this Point of usecase 🙂

    I have added a "chmod(ttyname(pty_slave), S_IRWXU | S_IRWXG | S_IRWXO);"

    That gives the rest of the world "enough" rights to work with the pseudo tty port.

    So my Installation with PiGatewaySerial and fhem connected over the tty port ist running fine for the last day with the above modification.

    Andreas


  • Code Contributor

    @Andreas-Maurer It's not my code, I have a raspberry pi laying around here, so I thought giving it a try. Glad to hear that you found the solution to those problems.



  • @Andreas-Maurer andreas could u share what akk shd be changed for the rasp pi 2 ?



  • Out of my mind:

    Change in bcm2835.h from

    define BCM2835_PERI_BASE               0x20000000
    

    to

    define BCM2835_PERI_BASE               0x3F000000
    

    and

    sudo make clean all install
    

    Change in PiGatewaySerial.cpp from

    gw = new MyGateway(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ, 60);
    

    to

    gw = new MyGateway(RPI_BPLUS_GPIO_J8_15, RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ, 60);
    

    thats depends on the GPIO Pins you use. These are from the sample.

    hope that was all. Please come back if it doesnt work.



  • And dont forget to enable SPI in the PI config tool.


Log in to reply
 

Suggested Topics

49
Online

11.4k
Users

11.1k
Topics

112.7k
Posts