LowPowerLab Forum

Software support => Pi Gateway => Topic started by: frix on October 01, 2017, 07:51:23 PM

Title: Gateway app /serial port not running
Post by: frix on October 01, 2017, 07:51:23 PM
Hi Felix,

Super noob here. A few years back I bought an RPi (B) with all the excitement in the world just to put it away like most people I know. Finding moteinos and the gateway app finally gave it some purpose, so I've been working on setting my gateway all weekend.

I got a fresh install of the latest raspbian with NOOBS (downloaded 09/31/17), and got the gateway with your script. Everything looked peachy but I can't get the app to work. It gets stuck in the "waiting for socket" state and just won't get past it.

Right now I'm testing the system with a gateway mote connected to ttyAMA0 and another mote with the weather shield. I just confirmed it's all working fine by reading some serial with minicom.

I'm not that versed on Linux, so I really don't know how to check if the gateway process is running or not, but looking online I found two commands:

systemctl
and didn't see the gateway there.

then ran
ps aux | grep gateway
and I get:
pi         929  0.0  0.9   4368  1808 pts/0    S+   19:46   0:00 grep --color=auto gateway

If I look for any Log in the /gateway folder I can't seem to find any log file so I don't have any error to look at/report.

I think the app is not running. Any pointers?

Thanks!
Oscar
Title: Re: Gateway app not running
Post by: Kilo95 on October 01, 2017, 08:35:25 PM
make sure that you run

sudo raspi-config

and disable the serial console but leave the serial adapter enabled and reboot


you can then run:

sudo apt-get install minicom

minicom -b 19200 -o -D /dev/ttyAMA0


see if you get output from your Weathershield there
Title: Re: Gateway app not running
Post by: frix on October 01, 2017, 08:54:44 PM
Hi Kilo95,

One of the pics I attached shows the output of minicom, and you can see that the weathershield is being read by the gateway moteino and that the gateway moteino is reporting via serial those readings. So my serial is running OK (just ran it again and it still works)

But then I did:

cd ~/gateway
node gateway.js &

and got the following error:
pi@FrivoPi:~/gateway $ node gateway.js &
[1] 993
pi@FrivoPi:~/gateway $ [10-01-17_20:53:17.064] [INFO]  LOADING USER METRICS...
[10-01-17_20:53:17.210] [INFO]  LOADING USER METRICS MODULE [_example.js]
[10-01-17_20:53:17.615] [ERROR] Cannot open ttyAMA0


... so I guess the serial is not available?
Title: Re: Gateway app not running
Post by: sparky on October 01, 2017, 08:58:43 PM
How is your Moteino connected to your pi? GPIO or USB
Title: Re: Gateway app not running
Post by: frix on October 01, 2017, 09:07:57 PM
I got it wired to the GPIO.

Also, don't know why, but the website is not waiting for sockets anymore, it went past it and now it just shows that there's no nodes (which is expected). Ahh I feel I'm so close! haha

Thanks for helping!
Title: Re: Gateway app not running
Post by: Kilo95 on October 01, 2017, 09:14:59 PM
i ran into the same issue. my remote nodes are using an older version of the code set at 115200 bps. The newer PiGateway software is set at 19200 bps. I just set my Pi Gateway to 115200 bps under the settings tab on the Gateway. you might want to check that
Title: Re: Gateway app not running
Post by: frix on October 01, 2017, 09:22:27 PM
So checking... If I run:

Sudo systemctl | grep getty

I see that getty is still running (I thought I had disabled by following THIS  (https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/)post).

How I can set up my system so that getty stops being a greedy douche?

Title: Re: Gateway app not running
Post by: frix on October 01, 2017, 09:24:45 PM
Quote from: Kilo95 on October 01, 2017, 09:14:59 PM
i ran into the same issue. my remote nodes are using an older version of the code set at 115200 bps. The newer PiGateway software is set at 19200 bps. I just set my Pi Gateway to 115200 bps under the settings tab on the Gateway. you might want to check that

Yup, I checked. I've read a bunch of the forums post and that was one of the first things I checked. Everything here is running at 19200 bps.  I can verify that by running minicom. I think the problem is that the serial is being hijacked by getty or other service.
Title: Re: Gateway app not running
Post by: sparky on October 01, 2017, 09:33:12 PM
Felix just posted some commands the other day to check what might be using the serial port;

https://lowpowerlab.com/forum/pi-gateway/just-updated-to-jessie-and-the-new-pi-gateway/msg20878/#msg20878

Title: Re: Gateway app not running
Post by: Felix on October 01, 2017, 10:19:47 PM
@frix - I think you're really close. The serial GPIO console must be enabled and disconnected from the system console.
I posted some instructions in this guide page (https://lowpowerlab.com/guide/gateway/possible-known-issues/).
Title: Re: Gateway app not running
Post by: frix on October 01, 2017, 11:55:30 PM
I've done everything in every guide I can find. Including yours. But I just can't figure out how to enable the serial properly. My frustration comes from the fact that I can actually read ttyAMA0 with minicom, but the gateway can't access ttyAMA0 even though I'm using the same settings.

Do you think this has anything to do with me running this on the newest, freshest version of Raspbian (Stretch)? All the guides I see are for older versions.

Otherwise, am I missing something? Felix, have you been able to try the gateway with Raspbian Stretch?

Thanks!
Title: Re: Gateway app not running
Post by: frix on October 02, 2017, 12:28:26 AM
I'll check what they're saying on the raspberry forums and see if they have any solutions for the new distro. I'll keep you guys posted.

I also may just go ahead and get a moteino USB and get over this. haha

Oh, also, is there a reason why I need to manually go an start the app with node? I don't know how to set it so that it starts automatically on boot.

Thanks again!
Title: Re: Gateway app not running
Post by: Kilo95 on October 02, 2017, 12:52:23 AM
when I was having issues the other day, I was using a Moteino USB. I have no idea why you have to manually restart the node. I use Felix's Weathershield sketch on one end, a PiGateway sketch on the other. For the RPi, I used PiBakery and went through Felix's steps. It worked fine after I set the transfer rate correctly
Title: Re: Gateway app not running
Post by: Felix on October 02, 2017, 08:53:53 AM
It may have to do with Stretch, i havent tried it yet. In the past, with every new release, there were "breaking" changes to what people were used to. It may be the case here as well.
The setup script installs the gateway to automatically start up when you power the Pi. I will have to look into it when I get a chance. In the meantime if you find a solution please share.
Title: Re: Gateway app not running
Post by: frix on October 07, 2017, 10:17:22 PM
Hi Felix,

Thanks for your replies. Honestly I couldn't find any answers or work-arounds. Maybe if I was more knowledgeable of Linux I could have found something... but what I ended up doing was buying one of your Moteinos USB and that worked like a charm. I now have a working gateway.

I guess I'll keep looking for an answer, both because I believe that the GPIO serial has to be usable, and because of the honor, hahaha.

In the meantime, it would be great if you could check both your install script and gateway with Stretch, and see if you get in any similar issues.

Thanks again!
Oscar
Title: Re: Gateway app not running
Post by: HeneryH on October 08, 2017, 10:14:07 AM
I just build a system and found a couple of trouble areas. 

The new version of Raspian handled serial ports differently than the older ones.  You need to make sure that you have a /dev/tty* active.  I'll post my notes in a couple of minutes.  I need to log off/on to get them.
Title: Re: Gateway app not running
Post by: HeneryH on October 08, 2017, 10:46:51 AM
The Jessie and newer versions of raspbian handle serial ports differently than the older versions.  When all is said an done, make sure that if you "ls /dev/tty*" you see the ttyAMA0 device

https://www.cube-controls.com/2015/11/02/disable-serial-port-terminal-output-on-raspbian/   or if I try to go to the documentation from the Pi itself https://www.raspberrypi.org/documentation/configuration/uart.md
Title: Re: Gateway app not running
Post by: frix on October 08, 2017, 11:39:04 AM
Ahh... Thanks for those links. I think I should read more about the UART and how to configure it.

If I'm reading it right (and please correct me if I'm wrong), the new raspbian distributions assume you'll have a new  pi with Bluetooth, so the serial pins are being assigned to it. This would mean that besides disabling the serial in the config, I need to enable device tree overlays so the kernel knows how to use the TX RX pins.

I'll try that and let you know if I blew up my life or not.

Cheers!
Title: Re: Gateway app not running
Post by: HeneryH on October 08, 2017, 12:00:13 PM
Two impactful changes recently 1) Jessie version does things differently and 2) the Pi3 has the Bluetooth issue with serial port.  Look into both.
Title: Re: Gateway app not running
Post by: Kilo95 on October 09, 2017, 10:06:35 PM
As far as having a ttyAMA0...that is correct unless you're using a Moteino USB. In that case, you want to see ttyUSB0
Title: Re: Gateway app not running
Post by: Felix on October 10, 2017, 12:11:39 PM
frix,
Good that you got it working with the MoteinoUSB + /dev/ttyUSB0.
I will check the script with the latest distro as time permits.
Thanks for coming to the forum.