Hi,
I recently upgraded to RouterOS v6.44 and I now have and issue with a script that was logging GPS position to text file. The script is as follows:
:local LAT;
:local LONG;
:local ALT;
:local SPEED;
:local SAT;
:local QUAL;
/system gps monitor without-paging once do={
:log info “LAT: $latitude , LONG: $longitude , ALT: $altitude , SPEED: $speed , SAT: $satellites”;
};This results in the above values being shown in the live log output on screen, but the resultant text file only contains the first value for “LAT”, no LONG, ALT, SPEED or SAT.
When I look at the live log file, it seems there is now a long space or tab after the Latitude and Longitude values (between the actual value for latitude and the separating comma). I’m guessing this is some character that is preventing the text from being written to file. Image below showing the log file:
It makes no difference what the coordinate format is set to. Is there an adjustment to the syntax for latitude and longitude I can make to clean up the output?
Update on this: If i run “len” on latitude and longitude, it counts 32 characters for each, even though only 9 are visible in the log. I have created a pick script that takes the first 9 ascii characters from the latitude and longitude fields and sends these to the text file. This will only work if the number of characters output by the GPS remains constant, so I am using decimal degrees rather than degrees, minutes and seconds since that format varies in character length much more. The question remains why I need to do this in RouterOS v6.44 as it worked in previous versions without needing to pick characters.
v6.44 seems to be the first release to offer different coordinate formats (dd, dms and ddmm). Could it be that in fact all three formats are being sent as an output to the fields for latitude and longitude and that the selection tool is somehow masking the text for the unwanted formats? If that were the case, could there be some delineation or separation character?
Hi eworm. Fantastic, that has sorted it, thank you. Though I’m not seeing the trailing zeros (or any characters) when I run /sys scr env pri, but your two lines work nonetheless. That has saved me a big headache, I owe you a beer.
If you run your script from the CLI then it shows the problem.
08:47:08 script,info LAT: S xx y' zz.zzz''\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 , LONG: E xx y' zz.zzz''\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 , ALT: 1581.000000m , SPEED: 0.0
92600 km/h , SAT: 8
The latitude and longitude fields are null filled. Seems like a bug to me. Best option for now is to pick the value out of the null byte filled string. This works on my RB912 with 6.44.3. Tested with all three formats, DMS, DDMM and DD.
/system gps monitor without-paging once do={
:local format [/system gps get coordinate-format]
:local rawLatitude $("latitude")
:local rawLongitude $("longitude")
:local lat [:pick $rawLatitude 0 [:find $rawLatitude "\00" -1] ]
:local long [:pick $rawLongitude 0 [:find $rawLongitude "\00" -1] ]
:log info "FORMAT: $format, LAT: [$lat] , LONG: [$long]";
}