I am kind of new to using the forums here and am a bit new to the Arduino (arduino mega 1280).
The problem that i am having is connecting 2 devices serially to the Arduino via serial2 and serial3 and using real-time update of GPS and SMS (via GSM). I am not exactly sure how to achieve a real-time update of both unless i should use interrupts or run each serial port X number of milliseconds then check next port for changes.
Basically what is happening is that when the GSM module receives a SMS message it will contain set information (GPS location, start, stop, resume,etc) and the GPS will be used to determine the location of the unit itself and which direction/how far the unit has to go to reach the destination. so the GSM part will only be when a SMS is received, but the GPS needs to be mainly real time probably at least every 2 seconds just to be sure.
Then if the message lenghts aren't too long you can wait in a loop for the SMS, parse that then get info from the GPS and do whatever.
That's the easy way but IMO not the best way.
Probably better is something like this
loop () {
if (Serial2.available() > 0 {
add character to SMS buffer
if end of packet
do stuff based on current GPS value already stored in variables
}
if (Serial3.available() > 0 {
add character to GPS buffer
if end of packet
calc current location and place in variables
}
}
I'll go ahead and try that when everything comes in. Just have to wait on the lovely shipping companies..... lol
I hope this all works when it comes in, i'll post back if anything else comes up and keep it updated as I get parts together and working.