如何通过可可应用程序从USB GPS设备读取NMEA数据 [英] How to read NMEA data from USB GPS device through cocoa application

查看:533
本文介绍了如何通过可可应用程序从USB GPS设备读取NMEA数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 USB GlobalSat(USG-MR350) GPS装置。我想从我的mac可可应用程序中的设备获取位置数据(纬度和经度)。尝试运行 AMSerialPort 示例代码。它正在检测usb设备,但它在不可读格式。此数据如何转换为可读格式。这是源代码的一部分:

I am using USB GlobalSat(USG-MR350) GPS device. I want to get location data (latitude and longitude) from the device within my mac cocoa application.Tried to run the AMSerialPort sample code.It is detecting the usb device but it is giving output in nonreadable format.How can this data be converted to readable format.This is a part of the source code:

- (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 *text = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
        [outputTextView insertText:text];
        [text release];
        // continue listening
        [sendPort readDataInBackground];
    } else { // port closed
        [outputTextView insertText:@"port closed\r"];
    }
    [outputTextView setNeedsDisplay:YES];
    [outputTextView displayIfNeeded];
}


推荐答案

正在检查端口设置。

串行端口 NMEA 的默认设置为速度:4800stopbit:1 parity:none

Default settings for NMEA over serial port is speed:4800stopbit:1 parity:none.

在设备上检查。

这篇关于如何通过可可应用程序从USB GPS设备读取NMEA数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆