Community discussions

MikroTik App
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

LTAP Mini serial port / GPS

Sun Aug 07, 2022 3:21 pm

Hi all
I have a LTAP mini up and working.
What I am wanting to do is get the GPS working over a remote-access serial port. This would enable me to run GPSD on another machine using SOCAT to access the serial stream over TCP.
I did have this up and working per this post on a different forum however I can not get it to work again since restarting the router.https://community.victronenergy.com/que ... twork.html
I believe the issue is that by not enabling the GPS on the router im not switching the port over from the external DB9 port to the GPS chip. Im of this belief because when I "/system serial-terminal serial0" I get no data, and it seems this serial0 is shared between the DB9 port and the GPS chip.
Is there any way to enable this port to change over to the GPS chip so I can remote-access the port and see the NMEA data over TCP?
Regards, Mike.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: LTAP Mini serial port / GPS

Tue Aug 09, 2022 9:12 am

What is the output of the following commands?
/port print
/system console print
/system gps print
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

Re: LTAP Mini serial port / GPS

Tue Aug 09, 2022 2:26 pm

Hi, Thanks for taking the time to read my post and possibly help.
Output of those commands are as follows.

[admin@MikroTik] > /port print
Flags: I - inactive
# DEVICE NAME CHANNELS USED-BY BAUD-RATE
0 serial0 1 remote-access auto
1 usb2 1 9600
[admin@MikroTik] > /system console print
Flags: X - disabled, U - used, F - free
# PORT TERM
0 X serial0 vt102
[admin@MikroTik] > /system gps print
enabled: no
port: serial0
channel: 0
init-string:
set-system-time: yes
coordinate-format: dd
gps-antenna-select: internal
[admin@MikroTik] >

Thanks again, Regards, Mike.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: LTAP Mini serial port / GPS

Tue Aug 09, 2022 2:57 pm

OK. There is the "real" LtAP in my attic, which has two serial ports, so I am not able to offer any hands-on experience with LtAP mini, but the remark in the manual that suggests that the only serial port of the LtAP mini is switched automatically between the external DB-9 and the GPS, together with the step in the article on the other forum ("test and then disable the GPS functionality on the router under /system gps"), give a hint that this automatic switchover is not thorough enough and leaves the switch in the "gps" position if you first enable the GPS and then disable it. Which is incorrect in general but good for your purpose.

So I'd try exactly that - disable the remote access configured on serial0, enable the GPS, disable it again, and re-enable the remote access. If this sequence makes the GPS visible to the gpsd on the external machine, I can give you a script that will do exactly this automatically on every reboot (as in "every power restoration").
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

Re: LTAP Mini serial port / GPS

Tue Aug 09, 2022 11:19 pm

Thanks Sindy,

Yes so that was what I think happened.
I wrote the article on the Victron forum, but unfortunately cant get this to work again using the same sequence. The initial setup I had working prior to writing that article did not survive a reboot of the router and I cant replicate it.
I would love to see what sort of command is issued in the background to switch the serial port over and add that into my setup instructions.

Regards, Mike.
 
sindy
Forum Guru
Forum Guru
Posts: 10205
Joined: Mon Dec 04, 2017 9:19 pm

Re: LTAP Mini serial port / GPS

Tue Aug 09, 2022 11:47 pm

What is the complete command tree under /system routerboard ? On the "big" LtAP, there is /system routerboard usb set type, used to switch the second USB inteface between the external USB connector and the second miniPCIe slot, so I'd guess that if switching the serial port is exposed into configuration, it should be somewhere there. But if it was like that, it should survive a mere reboot (i.e. not resetting the configuration to defaults), so I'm afraid it might be that the deactivation of the GPS normally switches the interface back to the DB-9 automatically and it was just a "lucky glitch" that has lead to success before.
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

Re: LTAP Mini serial port / GPS

Wed Aug 10, 2022 12:34 pm

Intetresting re the USB ports on the full size, that gives me some hope!
Im not sure how to display the command tree. Can you explain how to show this?
Many thanks, Mike
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: LTAP Mini serial port / GPS

Wed Aug 10, 2022 12:54 pm

Using CLI: go into /system routerboard and press [TAB] key ... it should display available commands and configuration branches at this point.
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

Re: LTAP Mini serial port / GPS

Wed Aug 10, 2022 1:36 pm

Thanks MKX,
I get
[admin@MikroTik] /system/routerboard>
mode-button reset-button settings usb wps-button export get print upgrade

I see the path to change the USB port as you mention but nothing there for serial0.

Also took a look at /system/routerboard/settings/set but cant think any of these would be it either.

[admin@MikroTik] /system/routerboard> settings/set
auto-upgrade boot-os disable-pci gpio-function reformat-hold-button-max
baud-rate boot-protocol enable-jumper-reset init-delay regulatory-domain-ce
boot-delay cpu-frequency enter-setup-on protected-routerboot silent-boot
boot-device cpu-mode force-backup-booter reformat-hold-button

Anyone have any ideas? Im looking into options of getting a PCI card that includes a GPS chip as a workaround.

Cheers, Mike
 
nzmikec
just joined
Topic Author
Posts: 12
Joined: Sun Aug 07, 2022 3:15 pm

Re: LTAP Mini serial port / GPS

Wed Aug 10, 2022 1:42 pm

Also looked into /system/routerboard> settings/set and found GPIO function is serial1. GPS is on Serial0 but Is this something?

[admin@MikroTik] /system/routerboard> settings/set gpio-function=serial1
auto-upgrade boot-device cpu-frequency enable-jumper-reset init-delay reformat-hold-button-max
baud-rate boot-os cpu-mode enter-setup-on protected-routerboot regulatory-domain-ce
boot-delay boot-protocol disable-pci force-backup-booter reformat-hold-button silent-boot
 
GregW
just joined
Posts: 10
Joined: Sat Dec 29, 2018 9:15 pm

Re: LTAP Mini serial port / GPS

Fri Oct 14, 2022 8:27 pm

Hey nzmikec,

I have a LtAP mini and can confirm the same problem (routeros 7.5). I did some testing and managed to make the GPS output go via remote-access again. Did some trial and error to duplicate. I tested with normal reboots as well as removing power for a cold boot. So far so good although I will log a support ticket with Mikrotik as we have a bug here. So a fix later on might make this redundant.

I setup a script to do what is needed and a schedule job to execute the script after a reboot. This script can also be excuted by pressing the mode button. Let me know if it works for you.

/system/script {
    add name=enable-gps-for-remote-access comment="Prepare the GPS for access via remote access" dont-require-permissions=no policy=read,write,policy source="{\r\
    \n\r\
    \n:local remoteport \"10000\";\r\
    \n:local remoteprotocol \"raw\";\r\
    \n\r\
    \n# Turn off access to the serial0 port\r\
    \n/system/console/set [find where port=serial0] disabled=yes;\r\
    \n/port/remote-access/remove [find where port=serial0];\r\
    \n/system/gps/set enabled=no port=serial0;\r\
    \n\r\
    \n# setup remote access\r\
    \n/port/remote-access/add port=serial0 protocol=\$remoteprotocol tcp-port=\$remoteport;\r\
    \n\r\
    \n# Get GPS output on serial0 so that it can be accessed by remote-access\r\
    \n#\r\
    \n# this will fail but output to usb2 seems to \"trigger\" the GPS output\r\
    \n# put back to serial0 afterwards.\r\
    \n/system/gps/set port=usb2;\r\
    \n:delay 1000ms;\r\
    \n/system/gps/set enabled=yes port=serial0;\r\
    \n\r\
    \n}\r\
    \n"
}

/system scheduler {
    add name=remote-access-to-gps on-event="/system/script/run enable-gps-for-remote-access;" \
        policy=read,write,policy start-time=startup
}

/system routerboard mode-button {
    set enabled=yes on-event="/system/script/run enable-gps-for-remote-access;"
}

Change the local variables to suit your setup.
 
nebulight
just joined
Posts: 4
Joined: Fri Dec 25, 2020 4:51 am

Re: LTAP Mini serial port / GPS

Tue Nov 01, 2022 9:54 pm

Hmm, I'm getting failure: device is busy, check /port when I run this script.

I'm not even able to enable remote access on the serial port. I am using the LTE version if that makes a difference:

LtAP mini LTE (R11e-LTE-US)
 
GregW
just joined
Posts: 10
Joined: Sat Dec 29, 2018 9:15 pm

Re: LTAP Mini serial port / GPS

Sun Nov 13, 2022 3:53 pm

The error
failure: device is busy, check /port
is correct. The last command of the script enables the gps to use the serial port which fails as it is already in use for remote access. This is the trigger/bug that internally connects the GPS to serial0. Then connecting to the port specified for remote access gets you the GPS data.

I have only tested this running RouterOS 7.5. No idea if this will work on v6.

After some testing this morning I noticed that sometimes the scheduler executes the script very early in the boot sequence. I inserted a 30 second delay to let the LtAP settle. I also updated the script to log when it's running and cycle the gps port before enabling. There is no error message now as it is executed in a do/on-error block.
add comment="Prepare the GPS for access via remote access" dont-require-permissions=no name=enable-gps-for-remote-access owner=gregw policy=read,write source="{\r\
    \n\r\
    \n:log info (\"Starting remote GPS hack\");\r\
    \n\r\
    \n:local remoteport \"10000\";\r\
    \n:local remoteprotocol \"raw\";\r\
    \n\r\
    \n# Turn off access to the serial0 port\r\
    \n/system/console/set [find where port=serial0] disabled=yes;\r\
    \n/port/remote-access/remove [find where port=serial0];\r\
    \n/system/gps/set enabled=no port=serial0;\r\
    \n\r\
    \n# setup remote access\r\
    \n/port/remote-access/add port=serial0 protocol=\$remoteprotocol tcp-port=\$remoteport;\r\
    \n\r\
    \n# Get GPS output on serial0 so that it can be accessed by remote-access\r\
    \n#\r\
    \n# this will fail but output to usb2 seems to \"trigger\" the GPS output\r\
    \n# put back to serial0 afterwards.\r\
    \n/system/gps/set port=usb2;\r\
    \n:delay 1000ms;\r\
    \n/system/gps/set port=serial0;\r\
    \n:delay 1000ms;\r\
    \n:do {\r\
    \n  /system/gps/set enabled=yes port=serial0;\r\
    \n} on-error={\r\
    \n  : log info (\"triggering gps hack\");\r\
    \n}\r\
    \n\r\
    \n:log info (\"Finished remote GPS hack\");\r\
    \n}\r\
    \n"

/system scheduler {
    add name=remote-access-to-gps on-event=":delay 30s; /system/script/run enable-gps-for-remote-access;" \
        policy=read,write,policy start-time=startup
}

/system routerboard mode-button {
    set enabled=yes on-event="/system/script/run enable-gps-for-remote-access;"
}
 
GregW
just joined
Posts: 10
Joined: Sat Dec 29, 2018 9:15 pm

Re: LTAP Mini serial port / GPS

Sun Nov 13, 2022 4:01 pm

Upgraded to 7.6 and it still "works" as it did on 7.5
ltap-gps.png
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: Bing [Bot], ccrsxx, GoogleOther [Bot] and 71 guests