Community discussions

 
minoanson
just joined
Topic Author
Posts: 3
Joined: Thu Mar 24, 2016 3:10 pm

GPS speed to knots[SOLVED]

Fri Aug 30, 2019 5:11 pm

Hi to all,

i am trying to read into the mikrotik the speed of the gps from km/h to knots...
:local speedknots [$speed * 0.5399]
any suggestion?

Thanks
Last edited by minoanson on Mon Sep 02, 2019 3:56 am, edited 1 time in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1290
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: GPS speed to knots

Fri Aug 30, 2019 6:14 pm

It seems that RouterOS does not support decimals

But to do math, you need parentheses.
{
local speed 10
:put $speed
:local speedknots ($speed * 5)
:put $speedknots
}

 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
eworm
Member
Member
Posts: 376
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: GPS speed to knots  [SOLVED]

Fri Aug 30, 2019 10:23 pm

Hi to all,

i am trying to read into the mikrotik the speed of the gps from km/h to knots...
:local speedknots [$speed * 0.5399]
any suggestion?
How about this?
{
  :local speed 10;
  :local speedknots (($speed * 5399 / 10000) . "." . (($speed * 5399 / 10) - ($speed * 5399 / 10000 * 1000)));
  :put $speedknots;
}
This is ugly, but it works. :lol:
Note that $speedknots is a string, not a number. Your can print it, but you can not use it for more math.
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1290
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: GPS speed to knots

Sat Aug 31, 2019 10:05 am

Will be solved in ROS 7.......
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
minoanson
just joined
Topic Author
Posts: 3
Joined: Thu Mar 24, 2016 3:10 pm

Re: GPS speed to knots

Mon Sep 02, 2019 1:57 am

Hi to all,

i am trying to read into the mikrotik the speed of the gps from km/h to knots...
:local speedknots [$speed * 0.5399]
any suggestion?
How about this?
{
  :local speed 10;
  :local speedknots (($speed * 5399 / 10000) . "." . (($speed * 5399 / 10) - ($speed * 5399 / 10000 * 1000)));
  :put $speedknots;
}
This is ugly, but it works. :lol:
Note that $speedknots is a string, not a number. Your can print it, but you can not use it for more math.

thanks man! works perfect :)

Who is online

Users browsing this forum: Google [Bot] and 5 guests