• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
serial comm with GPS, not quite an NMEA sentence
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

serial comm with GPS, not quite an NMEA sentence


  • Subject: serial comm with GPS, not quite an NMEA sentence
  • From: Gonzalo Castro <email@hidden>
  • Date: Mon, 2 Oct 2006 23:58:58 -0400

Hello,

I'm learning how to get data from a serial device, specifically a GPS set to use NMEA protocol. I came across the following sample code, at http://www.harmless.de/cocoa.html#serialport.

The method below seems to be called when receiving data. Should I expect the NSData *data to contain an NMEA formatted string? Eg, "RMC, 225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68" (clipped from http://www.eoss.org/pubs/nmeafaq.htm). If so, then I'm not getting such a string. Instead, dataStr looks like garbage.

- (void)serialPortReadData:(NSDictionary *)dataDictionary
{
// this method is called if data arrives
// @"data" is the actual data, @"serialPort" is the sending port
AMSerialPort *sendPort = [dataDictionary objectForKey:@"serialPort"];
NSData *data = [dataDictionary objectForKey:@"data"];
if ([data length] > 0) {
NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"dataStr = %@", dataStr);
[outputTextView insertText:dataStr];
// continue listening
[sendPort readDataInBackground];
} else { // port closed
[outputTextView insertText:@"port closed\r"];
}
[outputTextView setNeedsDisplay:YES];
[outputTextView displayIfNeeded];
}


Thanks for any pointers.

Gonzalo


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: serial comm with GPS, not quite an NMEA sentence
      • From: Shawn Erickson <email@hidden>
    • Re: serial comm with GPS, not quite an NMEA sentence
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: Help: Data Modelling, NSTreeController and NSBrowser
  • Next by Date: Re: drags from iTunes in an NSView just like iWeb [Solved]
  • Previous by thread: Re: Help: Data Modelling, NSTreeController and NSBrowser
  • Next by thread: Re: serial comm with GPS, not quite an NMEA sentence
  • Index(es):
    • Date
    • Thread