Gaahhh...Software Serial (AFSoftSerial)

This is sort of the second half to an earlier discussion I started about problems with software serial that I was having with the Arduino. I didn't like the fact that the SoftwareSerial library would hang if serial input was abruptly cut off, so somebody recommended ladyada's AFSoftSerial library (originally posted about here). I hate to post about a similar topic twice, but after much experimentation, I realized that I probably don't have the technical knowledge yet to be able to understand the problem...What's happening is basically that the AFSoftSerial library is reading junk, just random characters, from the GPS module. However, I know that the GPS module is outputting correctly, because using the SoftwareSerial library, I get the output I want. Also, I know that it is indeed trying to read from the GPS module and not just floating because when I disconnect the wire from the GPS module to the Arduino, the junk stops. Also, I know that hyperterminal and the connection from my computer to the Arduino is formatted correctly because the Arduino sends a "hello" message when it boots, which is coming through perfectly.I did notice a pattern in the junk though. The GPS strings that the module is outputting look like:$GPVTG,...[other stuff]...and here's some sample output from AFSoftSerial, with line breaks placed at strategic points:D;jK¤;¹Ìcs¦3\£9Ëc3¹ÌdcÆ:Ë`sf3››S¦³SüD;jK¤;¹Æ2esF3\£9Ëc39ÌacÆD;jK¤;9D;jK¤;9ÆThis made me think at first that it was just a matter of shifting ascii codes, but shifted so that "D" becomes "$", the rest of the message is still unintelligible. It also sort of looks like a timing issue, but I tried changing the bit delay everywhere from 188 to 270 microseconds (the GPS module is outputting at 4800 baud) with no avail.I would welcome any thoughts on this -- I know it's sort of a complex issue, but I really don't know where to go from here...

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • AFSoftSerial is somewhat outdated also, might help to try upgrading to
    http://sundial.org/arduino/?page_id=61
    which builds on the Lady's library.

    If you are still completely stuck you may want to give it a shot after all else fails
    NewSoftSerial « Arduiniana
  • Check the data bytes. I had this before, it was set to 7bits rather than 8.
  • $GPV = 0x24 0x47 0x50 0x56 (hex)
    = 00100100 01000111 01010000 01010110 (binary)

    D;jK¤ = 0x44 0x3B 0x6A 0xA4 (hex)
    = 01000100 00111011 01101010 10100100 (binary)

    First byte looks similar in lower 5 bits, then another bit gets to wrong position. So changing delays could help.
  • Hi,

    Perhaps a dumb comment but looking at the output...
    Do you have speed and bits set correctly? The above looks to me exactly like 7bit characters read when expecting 8bit or viceversa...
    You have 8bit and 7bit serial comms and they do look exactly like above when one end is set wrong.
    Either that or it is shifting bits or something like this
  • Did you ever get this sorted? I am having exactly the same problem and not really getting much help from Ladyada

    Thanks in advance, Garth
This reply was deleted.

Activity