DLMUK
Member
These are some examples written specifically from Crimson 3.
It is worth googling "crimson 3 reference manual" it is very useful.
Simple action of printing the value of a tag out of a 232/485 port:
PortPrint (2,AsText(PAXI.distance));
PortPrint (2,",");
PortPrint (2,AsText(PAXI.speed/10.0));
PortPrint (2, "\r\n");
Program taking a raw RS232 input into a port and processing it into data tags:
cstring String;
cstring GPSHeader,NSInd,EWInd;
int Lat,LatMin,LatSec,Long,LongMin,LongSec,nos;
//initialize mydata with data string
String = PortInput(1, 0, '\r', 2000, 0); //rs232
//PortInput(PORT, START, END, TIMEOUT, LENGTH)
if(String != "")
{
//Sentence Identifier (Value &GPGGA)
GPSHeader := (Mid(GPS.rawString,1,Find(GPS.rawString,',',0)-1)); //find the value before first(1st) occurrence of ,
GPS.header := GPSHeader; // stores string header in tag GPS.header as string value
//Latitude (Value ddmm.mmmm)
Lat := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +1) +1,2),10); //find the value after second(2nd) occurrence of , in the 232 string.
GPS.Lat := Lat;// Latitude postion in decimal stored in GPS.Lat as int data
LatMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) -2,2),10); //find the value before first(1st) occurrence of . in the 232 string.
GPS.LatMin := LatMin;// Latitude postion in decimal stored in GPS.Lat as int data
LatSec := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) +1,4),10); //find the value after first(1st) occurrence of . in the 232 string.
GPS.LatSec := LatSec;// Latitude postion in decimal stored in GPS.Lat as int data
//Latitude Hemisphere (Value N or S)
NSInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +2) +1,1)); //find the value after third(3rd) occurrence of , in the 232 string.
GPS.NSInd := NSInd;// North or South value stored in GPS.NSInd as string data
//Longitude (Value dddmm.mmmm)
Long := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +3) +1,3),10); //find the value after fourth(4th) occurrence of , in the 232 string.
GPS.Long := Long;//Longitude position in decimal stored in GPS.Long as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) +1,5),10); //find the value after second(2nd) occurrence of . in the 232 string.
GPS.LongSec := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) -2,2),10); //find the value before second(2nd) occurrence of . in the 232 string.
GPS.LongMin := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data
//Longitude Hemisphere (Value E or W)
EWInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +4) +1,1)); //find the value after fifth(5th) occurrence of , in the 232 string.
GPS.EWInd := EWInd;// East or West value stored in GPS.EW Ind as string data
//Number of Satellites (Value 0-12)
nos := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', 0) +1,2),10); //find the value after sixth(6th) occurrence of , in the 232 string.
GPS.nos := nos;// Number of satellites being used stored in GPS.nos as int data
GPS.rawString := String; //Contains raw string data from GPS
// Activates flag tags for GPS Hemisphere indicators
if (GPS.NSInd == "N")
(GPS.NSInd_Bool := 1);
if (GPS.NSInd == "S")
(GPS.NSInd_Bool := 0);
if (GPS.EWInd == "E")
(GPS.EWInd_Bool := 1);
if (GPS.EWInd == "W")
(GPS.EWInd_Bool := 0);
}
It is worth googling "crimson 3 reference manual" it is very useful.
Simple action of printing the value of a tag out of a 232/485 port:
PortPrint (2,AsText(PAXI.distance));
PortPrint (2,",");
PortPrint (2,AsText(PAXI.speed/10.0));
PortPrint (2, "\r\n");
Program taking a raw RS232 input into a port and processing it into data tags:
cstring String;
cstring GPSHeader,NSInd,EWInd;
int Lat,LatMin,LatSec,Long,LongMin,LongSec,nos;
//initialize mydata with data string
String = PortInput(1, 0, '\r', 2000, 0); //rs232
//PortInput(PORT, START, END, TIMEOUT, LENGTH)
if(String != "")
{
//Sentence Identifier (Value &GPGGA)
GPSHeader := (Mid(GPS.rawString,1,Find(GPS.rawString,',',0)-1)); //find the value before first(1st) occurrence of ,
GPS.header := GPSHeader; // stores string header in tag GPS.header as string value
//Latitude (Value ddmm.mmmm)
Lat := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +1) +1,2),10); //find the value after second(2nd) occurrence of , in the 232 string.
GPS.Lat := Lat;// Latitude postion in decimal stored in GPS.Lat as int data
LatMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) -2,2),10); //find the value before first(1st) occurrence of . in the 232 string.
GPS.LatMin := LatMin;// Latitude postion in decimal stored in GPS.Lat as int data
LatSec := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +0) +1,4),10); //find the value after first(1st) occurrence of . in the 232 string.
GPS.LatSec := LatSec;// Latitude postion in decimal stored in GPS.Lat as int data
//Latitude Hemisphere (Value N or S)
NSInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +2) +1,1)); //find the value after third(3rd) occurrence of , in the 232 string.
GPS.NSInd := NSInd;// North or South value stored in GPS.NSInd as string data
//Longitude (Value dddmm.mmmm)
Long := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', +3) +1,3),10); //find the value after fourth(4th) occurrence of , in the 232 string.
GPS.Long := Long;//Longitude position in decimal stored in GPS.Long as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) +1,5),10); //find the value after second(2nd) occurrence of . in the 232 string.
GPS.LongSec := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data
LongMin := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, '.', +1) -2,2),10); //find the value before second(2nd) occurrence of . in the 232 string.
GPS.LongMin := LongMin;// Latitude postion in decimal stored in GPS.Lat as int data
//Longitude Hemisphere (Value E or W)
EWInd := (Mid(GPS.rawString, Find(GPS.rawString, ',', +4) +1,1)); //find the value after fifth(5th) occurrence of , in the 232 string.
GPS.EWInd := EWInd;// East or West value stored in GPS.EW Ind as string data
//Number of Satellites (Value 0-12)
nos := TextToInt (Mid(GPS.rawString, Find(GPS.rawString, ',', 0) +1,2),10); //find the value after sixth(6th) occurrence of , in the 232 string.
GPS.nos := nos;// Number of satellites being used stored in GPS.nos as int data
GPS.rawString := String; //Contains raw string data from GPS
// Activates flag tags for GPS Hemisphere indicators
if (GPS.NSInd == "N")
(GPS.NSInd_Bool := 1);
if (GPS.NSInd == "S")
(GPS.NSInd_Bool := 0);
if (GPS.EWInd == "E")
(GPS.EWInd_Bool := 1);
if (GPS.EWInd == "W")
(GPS.EWInd_Bool := 0);
}
Last edited: