| Author |
Message |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
Posted: 05 August 2008, 17:27 PM Post subject: ETEK GPS Module |
|
|
Hi Guys
Im using a ETEK EB-85A gps module, and just need a bit of advice on communicating with it. I have data coming into the zx-24n fine but I need to send some config packets to change settings.
This is the manual for packet forming http://www.sparkfun.com/datasheets/GPS/MTK%20Packet_User%20Manual.pdf
Im having problems sending them, If I try to send the following for example, I don't get the response confirmation package back, so something must be wrong.
I thought it would just be something like this, where the command to send is...
$PMTK000*32<CR><LF>
| Code: | | Call PutQueueStr(com2RXQueue, "$PMTK000*32") |
Any ideas whats wrong with that, does PutQueueStr include <CR> and <LF> at the end by default?
Thanks
Ben |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 05 August 2008, 17:59 PM Post subject: Re: ETEK GPS Module |
|
|
| sturgessb wrote: | | does PutQueueStr include CR and LF at the end by default? | It does not. That would limit the usefulness of the routine because you don't necessarily want an EOL on every string you send to a queue. Note, also, that the documentation for PutQueueStr() doesn't mention anything about extra characters appended so the safer assumption would be that it does not do so.
The simplest way to append a CR and LF to a string is to use the "string append" operator with a constant, e.g.
| Code: | Const CRLF as String = Chr(&H0d) & Chr(&H0a)
...
Call PutQueueStr(com2RXQueue, "$PMTK000*32" & CRLF) |
Since the ZBasic compiler performs constant folding, there is no run-time penalty for using code like this. The compiler notices that the two string components are constant and replaces the expression with the equivalent single string.
An alternate method that you may wish to use is: | Code: | Const CRLF as String = Chr(&H0d) & Chr(&H0a)
...
Call PutQueueStr(com2RXQueue, "$PMTK000*32")
Call PutQueueStr(com2RXQueue, CRLF) | Note that this results in slightly larger and somewhat slower code. |
|
| Back to top |
|
 |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
Posted: 05 August 2008, 18:28 PM Post subject: |
|
|
Thanks Don, although there must still be something wrong. I send it with the CRLF at the end and I get the same results as before, nothing back and the GPS stops outputting any data.
Has anyone in the forum used this GPS module?
Thanks
Ben |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 05 August 2008, 18:37 PM Post subject: |
|
|
| I just noticed that your example code refers to com2RXQueue. I would usually use a name like that for data received from an external device. In contrast, I would use com2TXQueue for a transmit queue, ie. data being sent to an external device. |
|
| Back to top |
|
 |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
Posted: 05 August 2008, 19:00 PM Post subject: |
|
|
| good catch, problem may be as simple as that silly mistake! |
|
| Back to top |
|
 |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
Posted: 05 August 2008, 19:27 PM Post subject: |
|
|
| is there any way to calculate the checksum value of a string easily? |
|
| Back to top |
|
 |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 05 August 2008, 21:31 PM Post subject: |
|
|
| sturgessb wrote: | | no worries, found the answer here |
I would recommend a slightly modified rendition of that routine as given below. The changes are:- Using the optional second parameter of Asc() to retrieve the desired character from the string. This avoids calling Mid() to produce a single character string multiple times.
- A local variable is introduced to hold the trimmed string. As originally written, if the passed string had leading whitespace the wrong characters would be used to compute the checksum. This step could be avoided if the caller passed a string that was already trimmed.
| Code: | Function NMEA_Checksum(sentence as String) As String
Dim i as Integer
Dim sum as Integer = 0
Dim str as String
str = Trim(sentence)
For i = 2 To Len(str) - 2
sum = sum Xor CInt(Asc(str, i))
Next i
NMEA_Checksum = Mid(cstrHex(sum), 3, 2)
End Function |
|
|
| Back to top |
|
 |
sturgessb
Joined: 25 Apr 2008
Location: Norwich, UK
|
|
Posted: 05 August 2008, 23:05 PM Post subject: |
|
|
| great, thanks Don! |
|
| Back to top |
|
 |
|