Community discussions

MikroTik App
 
Stiflerakos
newbie
Topic Author
Posts: 35
Joined: Sat Jan 14, 2017 1:28 pm

RB951G-2HnD & USB GPS Module

Thu Nov 10, 2022 4:20 pm

Deal all, good afternoon.
I have this router on os 6.48.6 and i have connect a USB GPS antenna in order to use it for polling location.
I am ok with scripting etc but when activate the antenna, it only works for few seconds and then stop and not all the times. I tried to change baudrate etc settings without success.
Any opinions?

Edit : When changing the baudrate , works for few seconds and stop. If i stop and start doesnt work again. Only after change baudrate.

My setup as below :
# nov/10/2022 16:14:04 by RouterOS 6.48.6
# software id = R9NY-9LNP
#
# model = RB951G-2HnD
# serial number = DE350F35AA20
/interface bridge
add admin-mac=DC:2C:6E:D3:6F:73 auto-mac=no comment=defconf name=bridge
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX \
    disabled=no distance=indoors frequency=auto installation=indoor mode=\
    ap-bridge ssid="MikroTik GPS" wireless-protocol=802.11
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk mode=dynamic-keys \
    supplicant-identity=MikroTik wpa-pre-shared-key=gr09gr09gr09
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp disabled=no interface=bridge name=defconf
/port
set 0 baud-rate=4800 name=usb1
/interface ppp-client
add apn=internet name=ppp-out1 port=usb1
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
    192.168.88.0
/ip dhcp-client
add comment=defconf disabled=no interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/system clock
set time-zone-name=Europe/Athens
/system gps
set coordinate-format=dms enabled=yes port=usb1
/system scheduler
add interval=1h name=gps on-event=gps policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    start-date=nov/08/2022 start-time=10:52:00
/system script
add dont-require-permissions=yes name=gps owner=admin policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
    local email \"giannis.karantanis.82@gmail.com\";\r\
    \n\r\
    \n:system gps monitor file=\"gps.txt\";\r\
    \n:global gpstext [/file get gps.txt contents];\r\
    \n:local longstart [:find \$gpstext \"longitude\" -1];\r\
    \n:local longend [:find \$gpstext \"\\n\" \$longstart];\r\
    \n:local latstart [:find \$gpstext \"latitude\" -1];\r\
    \n:local latend [:find \$gpstext \"\\n\" \$latstart];\r\
    \n:local validstart [:find \$gpstext \"valid\" -1];\r\
    \n:local validend [:find \$gpstext \"\\n\" \$validstart];\r\
    \n:local valid false;\r\
    \n:local zeros \"\";\r\
    \n\r\
    \n:if ([:find \$gpstext \"yes\" \$validstart] > 0) do={:set valid true;};\
    \r\
    \n\r\
    \n:global longitude [:pick \$gpstext (\$longstart + 11) \$longend];\r\
    \n:local degreestart [:find \$longitude \" \" -1];\r\
    \n:local minutestart [:find \$longitude \" \" \$degreestart];\r\
    \n:local secondstart [:find \$longitude \"'\" \$minutestart];\r\
    \n\r\
    \n:local secondend;\r\
    \n:local secfract;\r\
    \n\r\
    \n:if ([:len [:find \$longitude \".\" 0]] < 1) do={\r\
    \n    :set secondend [:find \$longitude \"'\" \$secondstart];\r\
    \n    :set secfract \"0\";\r\
    \n} else={\r\
    \n    :set secondend [:find \$longitude \".\" \$secondstart];\r\
    \n    :set secfract [:pick \$longitude (\$secondend + 1) (\$secondend + 2)\
    ];\r\
    \n};\r\
    \n\r\
    \n:local longdegree;\r\
    \n:local longdegreelink;\r\
    \n\r\
    \n:if ([:pick \$longitude 0 1] = \"W\") do={\r\
    \n    :set longdegree \"-\";\r\
    \n    :set longdegreelink \"W\";\r\
    \n} else={\r\
    \n    :set longdegree \"+\";\r\
    \n    :set longdegreelink \"E\";\r\
    \n};\r\
    \n\r\
    \n:set longdegree (\$longdegree . [:pick \$longitude 2 \$minutestart]);\r\
    \n:set longdegreelink (\$longdegreelink . [:pick \$longitude 2 \$minutesta\
    rt]);\r\
    \n:local longmin [:pick \$longitude (\$minutestart + 1) \$secondstart];\r\
    \n:local longsec [:pick \$longitude (\$secondstart + 2) \$secondend];\r\
    \n:local longfract ((([:tonum \$longmin] * 6000) + ([:tonum \$longsec] * 1\
    00) + ([:tonum \$secfract] * 10) ) / 36);\r\
    \n\r\
    \n:while (([:len \$zeros] + [:len \$longfract]) < 4) do={\r\
    \n    :set zeros (\$zeros . \"0\");\r\
    \n};\r\
    \n\r\
    \n:global newlong (\$longdegree . \".\" . \$zeros . \$longfract);\r\
    \n:global newlonglink (\$longdegreelink . \".\" . \$zeros . \$longfract);\
    \r\
    \n\r\
    \n:global latitude [:pick \$gpstext (latstart + 10) \$latend];\r\
    \n:set degreestart [:find \$latitude \" \" -1];\r\
    \n:set minutestart [:find \$latitude \" \" \$degreestart];\r\
    \n:set secondstart [:find \$latitude \"'\" \$minutestart];\r\
    \n\r\
    \n:if ([:len [:find \$latitude \".\" 0]] < 1) do={\r\
    \n    :set secondend [:find \$latitude \"'\" \$secondstart];\r\
    \n    :set secfract \"0\";\r\
    \n} else={\r\
    \n    :set secondend [:find \$latitude \".\" \$secondstart];\r\
    \n    :set secfract [:pick \$latitude (\$secondend + 1) (\$secondend +2)];\
    \r\
    \n};\r\
    \n\r\
    \n:local latdegree;\r\
    \n:local latdegreelink;\r\
    \n\r\
    \n:if ([:pick \$latitude 0 1] = \"N\") do={\r\
    \n    :set latdegree \"+\";\r\
    \n    :set latdegreelink \"N\";\r\
    \n} else={\r\
    \n    :set latdegree \"-\";\r\
    \n    :set latdegreelink \"S\";\r\
    \n};\r\
    \n\r\
    \n:set latdegree (\$latdegree . [:pick \$latitude 2 \$minutestart]);\r\
    \n:set latdegreelink (\$latdegreelink . [:pick \$latitude 2 \$minutestart]\
    );\r\
    \n:local latmin [:pick \$latitude (\$minutestart + 1) \$secondstart];\r\
    \n:local latsec [:pick \$latitude (\$secondstart + 2) \$secondend];\r\
    \n:local latfract ((([:tonum \$latmin] * 6000) + ([:tonum \$latsec] * 100)\
    \_+([:tonum \$secfract] * 10)) / 36);\r\
    \n\r\
    \n:set zeros \"\";\r\
    \n\r\
    \n:while (([:len \$zeros] + [:len \$latfract]) < 4) do={\r\
    \n    :set zeros (\$zeros . \"0\");\r\
    \n};\r\
    \n\r\
    \n:global newlat (\$latdegree . \".\" . \$zeros . \$latfract);\r\
    \n:global newlatlink (\$latdegreelink . \".\" . \$zeros . \$latfract);\r\
    \n\r\
    \n:global coordinates (\$newlong . \",\" . \$newlat);\r\
    \n\r\
    \n:global linkout \"http://maps.google.com\?q=\$newlatlink+\$newlonglink\"\
    ;\r\
    \n\r\
    \n:global kmlout \"<\?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"\?>\r\
    \n<kml xmlns=\\\"http://www.opengis.net/kml/2.2\\\">\r\
    \n  <Placemark>\r\
    \n    <name>M/V GR09</name>\r\
    \n    <description>M/V GR09 location</description>\r\
    \n    <Point>\r\
    \n      <coordinates>\$coordinates</coordinates>\r\
    \n    </Point>\r\
    \n  </Placemark>\r\
    \n</kml>\r\
    \n\";\r\
    \n\r\
    \n:if (valid) do={\r\
    \n    :global oldpos;\r\
    \n\r\
    \n    :if (\$oldpos != \$coordinates) do={\r\
    \n        /file set [/file find name=gps.kml] contents=\$kmlout\r\
    \n        /tool e-mail\r\
    \n        send to=\$email subject=\"Vessel moved\" body=\"Moved to \$latit\
    ude \$longitude\\r\\n\$linkout\\r\\n\$SMlinkout\" file=gps.kml\r\
    \n        :set oldpos \$coordinates;\r\
    \n     };\r\
    \n} else={\r\
    \n         /tool e-mail\r\
    \n         send to=\$email subject=\"Router gps position invalid\" body=\"\
    Router gps position invalid\"\r\
    \n};\r\
    \n\r\
    \n"
/tool e-mail
set address=64.233.166.108 from=example@gmail.com password=\
    xxxxxxxxxxxxxxxxxx port=587 start-tls=yes user=\
    example@gmail.com
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11381
Joined: Thu Mar 03, 2016 10:23 pm

Re: RB951G-2HnD & USB GPS Module

Thu Nov 10, 2022 7:36 pm

At the same time you have configured GPS under /system gps and PPP client under /interface ppp-client, both are using same pirt (usb1). Do you intend to use PPP client? If not, disable it.
 
Stiflerakos
newbie
Topic Author
Posts: 35
Joined: Sat Jan 14, 2017 1:28 pm

Re: RB951G-2HnD & USB GPS Module

Mon Nov 14, 2022 11:11 am

At the same time you have configured GPS under /system gps and PPP client under /interface ppp-client, both are using same pirt (usb1). Do you intend to use PPP client? If not, disable it.
Thank you very much for your reply !
You were right about this rule , it was disabled but i deleted anyway.
No changes so far.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10183
Joined: Mon Jun 08, 2015 12:09 pm

Re: RB951G-2HnD & USB GPS Module

Mon Nov 14, 2022 11:38 am

Check system->console and make sure the serial port is not a console.
 
Stiflerakos
newbie
Topic Author
Posts: 35
Joined: Sat Jan 14, 2017 1:28 pm

Re: RB951G-2HnD & USB GPS Module

Mon Nov 14, 2022 11:40 am

Console it is empty !

Who is online

Users browsing this forum: DanMos79 and 27 guests