rtklibexplorer / RTKLIB

A version of RTKLIB optimized for low cost GNSS receivers, especially u-blox receivers. It is based on RTKLIB 2.4.3 and is kept reasonably closely synced to that branch. This software is provided “AS IS” without any warranties of any kind so please be careful, especially if using it in any kind of real-time application.
http://rtkexplorer.com/
Other
674 stars 263 forks source link

RTKRCV autostart is not working #38

Open Selective031 opened 5 years ago

Selective031 commented 5 years ago

Hi,

I upgraded to the latest demo5 b31 and autostart is not working anymore. To make it start you need to telnet into the admin console, then a message comes up that the rtk service is starting.

This is my start command in /etc/rc.local on my Raspberry Pi: sudo /home/pi/RTKLIB/RTKLIB/app/rtkrcv/gcc/rtkrcv -o /home/pi/rtk.conf -s -p 5001 &

This worked perfectly in the b29 version.

rtklibexplorer commented 5 years ago

This must be a side affect of the commit I made on 11/23/18 which fixes the autostart when the rtkrcv console is open. I will look into this for my next release. In the meantime the code should work as before if you remove the 11/23/18 commit.

Selective031 commented 5 years ago

Thanks, I will remove the commit and see what happens.

vasimv commented 5 years ago

Same problem. I've restored lines

    if (start) {
        startsvr(NULL);
    }

And it is working now. Emlid's fork has a bit different, may be it is better:

   /* start rtk server */
    if (start) {
        if (startsvr(NULL) == 0)
            intflg = 1;
    }
Selective031 commented 5 years ago

I concur, restoring the lines makes it work as expected again.

Thanks,

GHolk commented 4 years ago

If I open RTKRCV console on tcp port, rtkrcv will start after I connect to the console, but not start when rtkrcv run. Is this an expected behavior?

I run rtkrcv on linux on raspberry pi, compile with gcc and default makefile.

I read the code. Are you willing to change this behavior? Maybe I can help.

Selective031 commented 4 years ago

If I open RTKRCV console on tcp port, rtkrcv will start after I connect to the console, but not start when rtkrcv run. Is this an expected behavior?

I run rtkrcv on linux on raspberry pi, compile with gcc and default makefile.

I read the code. Are you willing to change this behavior? Maybe I can help.

I made this python script as a workaround, just put it in rc.local file so it runs at startup:

import socket import time

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(('localhost', 5000)) client_socket.settimeout(10)

client_socket.send("admin" + '\r\n') time.sleep(1) client_socket.send("mypassword" + '\r\n') time.sleep(1) client_socket.close()

GHolk commented 4 years ago

@Selective031 thanks. Currently I fix it with echo exit | nc -Ct localhost 5000 after start rtkrcv process. However I do not like this behavior, so I want to change it.

GHolk commented 4 years ago

An ugly fix: https://github.com/GHolk/RTKLIB/commit/a53c87839fa84fd5e1c0440e56adf3c25f060b4b

RobinDumeige commented 4 years ago

This is still an issue. It's due to the fact that autostart is handled at creation of the first "console", should it be local or telnet. Since the local console is deactivated when using telnet, the first console is created when a telnet connection occurs and the "autostart" is handled at this time.

In my opinion you shouldn't deactivate locale console when using telnet. I like to have a local console on the machine dedicated to a service and be able to connect to it remotely when I need to. Using a flag or option to deactivate local console would be a better implementation to let people choose the behaviour they prefer for rtkrcv .

So the easy workaround for this issue is to activate the local console at all time. It's a pretty easy fix, you just need to remove the "else" condition around the block labelled /* open device for local console */ in the main() function.

RobinDumeige@e2e02d8

GHolk commented 4 years ago

however, it will cause error when run without terminal, like cron or systemd.

RobinDumeige commented 4 years ago

Well you can override the local console device with my fix using the -d option of rtkrcv. I've tried to set it to /dev/null with this command (works in a systemd service too, you just need to update the path to rtkrcv) : ./rtkrcv -p 12345 -s -d /dev/null I don't have a receiver or proper data to actually "run" rtkrcv since i'm confined at home, but when activating the debug trace I see that the autostart seems to be working without connecting with telnet. Could you try it and tell me if it's working on your end ?

RobinDumeige commented 4 years ago

there's nothing crazy in the systemd service unit file I used to test this, but just in case here is the content of it : [Unit] Description=RTKLIB (rtkrcv) Daemon #Wait until networks is up After=network-online.target

[Service] # just launching the binary in background Type=simple # user running the process User=myuser Group=mygroup

# path to binary ExecStart=/home/myuser/code/RTKLIB_Demo5/app/rtkrcv/gcc/rtkrcv -p 12345 -s -d /dev/null

# Restart automatically in case of error or processus killed/absent Restart=always

#syslog info SyslogIdentifier=rtkrcv SyslogFacility=local7 StandardOutput=syslog

[Install] WantedBy=multi-user.target

GHolk commented 4 years ago

thanks. the -d /dev/null does work.

RobinDumeige commented 4 years ago

Thanks for letting me know it's working ! I'll make a merge request later today.