Go Down

Topic: dual serial communication problem (GSM + GPS) (Read 1 time) previous topic - next topic

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.

Any advice would be greatly appreciated.

Thanks,
Friendlyghost89

Graynomad

Any reason you can't just add two Serial.reads to the main loop?

Code: [Select]
loop () {

  if (Serial2.available() > 0 {
     // do GPS stuff
  }

  if (Serial3.available() > 0 {
     // do SMS stuff
  }
}


If you are expecting long streams of data that needs to be parsed this simple approach may not be good.

What is the nature of the data and amount of processing that needs to be done on it?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Thanks for the quick reply.

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.

Thanks,
Erik

Graynomad

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

Code: [Select]
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
  }
}


______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Thankyou for the reply again.

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.

Thanks,
Friendlyghost89

SirPoonga

#5
Feb 11, 2011, 04:53 pm Last Edit: Feb 11, 2011, 04:55 pm by SirPoonga Reason: 1
What service/plan is your unit going to use, if you don't mind me asking?
i ask because I recently asked a GSM related question in project guidance
http://arduino.cc/forum/index.php/topic,51823.0.html

SirPoonga

I have an AT&T account currently so for testing i will be using that but the end result will probably be a T-Mobile pre-pay for about $15-20 a month.

The GSM shield that i am ordering is found at sparkfun: http://www.sparkfun.com/products/9607

you will also need at least a small antenna so just choose whichever meets your projects requirements.






Erik

SirPoonga

#7
Feb 11, 2011, 10:31 pm Last Edit: Feb 11, 2011, 10:54 pm by SirPoonga Reason: 1
Thanks for the info.  I see two routes to take.  Cellular is one, the other is APRS and ham radio.
http://trackuino.blogspot.com/

It isn't hard to get a ham radio license.  And it is a standard data format.  There are several sites you can use to track that data onto google maps.
http://aprs.fi/?call=a%2FN0KFB&mt=roadmap&z=14&timerange=21600

Go Up