Problem reading NMEA string


davec

Recommended Posts

I'm having difficulty with input from a GPS receiver. The receiver (HOLUX GR-213) streams standard NMEA strings without polling via a USB connection. It worked fine on an old laptop running Windows-2000 and DaqFactory Base v5.15, but not on my new PC running XP and DAQfactory Starter v5.79. I can see the stream in the monitor window and can parse it to variables that show up correctly in the Watch window, but when I follow the instructions in the Serial/Ethernet Communications Guide for "Creating a Protocol to Accept non-polled Data" nothing comes in (the Table tab of the Channel View remains empty). Here's a copy of the code used in my On Receive event for the comm device:

if (strIn == chr(10))
  private string datain = ReadUntil(10)
  private string head = Left(datain,6)
  if (head == "$GPRMC")
	Channel.AddValue(strDevice, 0, "RMC", 0, Parse(datain,1, ",")
  endif
endif

If I change 'Channel' in line 5 to the actual name of my channel (gpstest), then data starts appearing in the Channel view but all values are = 'gps' (the name I assigned to the comm device).

The Input and Channel parameters were all set up exactly as in the instructions, so what's wrong here?

Seems like the AddValue function isn't working as it should.

Link to comment
Share on other sites

Can you post a sample of the NMEA string you get, and perhaps your .ctl doc?

Personally, I don't use the way the serial guide suggests and instead use a regular sequence instead of a protocol. Its not as reusuable, but its easier to get working and debug. To do this, the sequence would look something like:

device.gps.purge()
private string datain
while (1)
   try
	  datain = device.gps.readuntil(10)
	  private string head = Left(datain,6)
	  if (head == "$GPRMC")
		 MyChannel.AddValue(strtodouble(Parse(datain,1, ",")))
	 endif  
   catch()
	  delay(0.1)
   endcatch
endwhile

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.