INCLUDE rtcu.inc
VAR_OUTPUT
gpsOK : BOOL;
gwOK : BOOL;
END_VAR;
VAR
DestNodeID : STRING:="@4711";
TXBuf : ARRAY[0..139] OF SINT;
tSend : DINT;
gps : gpsFix;
Lat : DINT;
Lon : DINT;
gpsTime : DINT;
END_VAR;
FUNCTION getINT:INT;
VAR_INPUT
adr : ptr;
END_VAR;
memcpy(dst:=ADDR(getInt),src:=adr,len:=SIZEOF(getINT));
END_FUNCTION;
FUNCTION getDINT:DINT;
VAR_INPUT
adr : ptr;
END_VAR;
memcpy(dst:=ADDR(getDINT),src:=adr,len:=SIZEOF(getDINT));
END_FUNCTION;
FUNCTION setINT;
VAR_INPUT
adr : ptr;
v : INT;
END_VAR;
memcpy(dst:=adr,src:=ADDR(v),len:=SIZEOF(v));
END_FUNCTION;
FUNCTION setDINT;
VAR_INPUT
adr : ptr;
v : DINT;
END_VAR;
memcpy(dst:=adr,src:=ADDR(v),len:=SIZEOF(v));
END_FUNCTION;
PROGRAM GPS_Tracker;
gpsPower(power:=TRUE);
gsmPower(power:=TRUE);
tSend:=clockNow() + 10;
DebugFmt(message:="gprsOpen=\1", v1:=gprsOpen());
BEGIN
gps();
IF clockNow() > tSend THEN
IF gps.mode > 1 THEN
tSend:=clockNow() + 10;
gpsTime:=gps.linsec;
Lat:=gps.latitude;
Lon:=gps.longitude;
DebugFmt(message:="gpsTime=\4", v4:=gpsTime);
DebugFmt(message:="Lattitude=\4", v4:=Lat);
DebugFmt(message:="Longitude=\4", v4:=Lon);
setDint(adr:=ADDR(TXBuf[0]), v:=gpsTime);
setDint(adr:=ADDR(TXBuf[4]), v:=Lat);
setDint(adr:=ADDR(TXBuf[8]), v:=Lon);
DebugFmt(message:="gsmSendPDU=\1", v1:=gsmSendPDU(phonenumber:=DestNodeID, message:=ADDR(TXBuf), length:=12));
END_IF;
END_IF;
gwOK:=gwConnected();
IF gps.mode > 1 THEN
gpsOK:=NOT gpsOK;
END_IF;
END;
END_PROGRAM;
|