Reading serial data from a serial GPS puck

I’m trying to set up the USBH_SerialUSB to read NMEA data that comes from a GPS puck.

The device type reported is 0 (unknown) but I know that just plugging in the GPS and leaving it for a minute will enable it to start spitting out sentences of GPS default data.

Based on the samples I did this:

protected void DeviceConnectedEvent(USBH_Device device)
{
Debug.Print(“Device connected…”);
Debug.Print("ID: " + device.ID + ", Interface: " +
device.INTERFACE_INDEX + ", Type: " + device.TYPE);
Debug.Print(device.PRODUCT_ID.ToString());
Debug.Print(device.PORT_NUMBER.ToString());
Debug.Print(device.VENDOR_ID.ToString());

   USBH_SerialUSB serial = new USBH_SerialUSB(device, 9600, Parity.None, 8, StopBits.One);
   serial.Open();

but when the serial setup runs the system throws an exception:

#### Exception System.Exception - 0xffffffff (3) ####
#### Message: 
#### GHIElectronics.NETMF.USBHost.USBH_SerialUSB::Init [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_SerialUSB::.ctor [IP: 0039] ####
#### Sunclipper1.Program::DeviceConnectedEvent [IP: 0086] ####
#### GHIElectronics.NETMF.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: a0207e83] ####
#### GHIElectronics.NETMF.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHIElectronics.NETMF.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####

A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll

@ RobRogjam - Which puck are you using? I have a GlobalSat BU-353 that I found for cheap on Amazon that I was going to try hacking on until @ ransomhall 's GPS module is finished. This puck uses the SiRF Star III chip, which is not the same chip (MTK3339) that a driver is available for.

I haven’t tried plugging it into the SerialUSB as you mention, can probably give it a whirl later tonight or tomorrow if no one else can come up with a solution right off for you.

I do know that based on other threads in the past though, you may need to write a specific driver for the type of chip (just like WiFi USB dongles)

Welcome to the forums @ robRogjam

you’re likely hitting the SiLabs issue. For the exact code you should use check out the Wiki GHI Electronics – Where Hardware Meets Software and see specifically this in the connected handler:

    case USBH_DeviceType.Unknown: // SiLabs but not recognized
                    // force SiLabs
                    USBH_Device silabs = new USBH_Device(device.ID,  
                         device.INTERFACE_INDEX, 
                         USBH_DeviceType.Serial_SiLabs, device.VENDOR_ID,  
                         device.PRODUCT_ID, device.PORT_NUMBER);
                    serialUSB = new USBH_SerialUSB(silabs, 9600, 
                         System.IO.Ports.Parity.None, 8, 
                         System.IO.Ports.StopBits.One);
                    serialUSB.Open();
                    serialUSBThread = new Thread(SerialUSBThread);
                    serialUSBThread.Start();
 

Good luck !

Its a Microsoft /Pharos GPS-360 that i got with streets and trips. Its been hanging about for ages unused so i thought i’d try to recycle it.

If i plug the thing in my Mac i just get a stream if serial sentences out. Theres no apparent setup needed on the puck.

I’m a bit aprehensive at writing a driver… I don’t know what that will intail. Do you mean like a gadgeteer module?

Hi Brett. Your post came in as i was replying to Steve.

Thanks for this info. i’ll give it a whirl!

Hmm, interesting. The silabs fix doesn’t work but I did discover that the serial device in the Pharos/Microsoft puck is a Prolific 2303 serial device.

Ok. Brilliant. Thanks Brett for pointing me in the right direction.

I used the following code:

        USBH_Device pharosGPS = new USBH_Device(device.ID,
      device.INTERFACE_INDEX,
      USBH_DeviceType.Serial_Prolific, device.VENDOR_ID,
      device.PRODUCT_ID, device.PORT_NUMBER);

       serialUSB = new USBH_SerialUSB(pharosGPS, 4800,
             System.IO.Ports.Parity.None, 8,
             System.IO.Ports.StopBits.One);
        serialUSB.Open();
        serialUSBThread = new Thread(SerialUSBThread);
       serialUSBThread.Start();

Note that the Pharos GPS spits out at 4800 Baud.

I now have GPS sentences!

Interesting development…

At this point I would always point out the USB discovery helper: http://www.tinyclr.com/codeshare/entry/115

Tell us what you get out of that.

This is what spits out of the USB discovery sample…

[Device, Port 0]
Type: Unknown
ProductID: 43680
VendorID: 1659
=== Interface ===
Class: Vendor Specific
SubClass: 0
Number: 0
Protocol: 0
Type: 4
– Endpoint –
Attributes: 3
Address: 129
Type: 5
Interval: 1

– Endpoint –
Attributes: 2
Address: 2
Type: 5
Interval: 0

– Endpoint –
Attributes: 2
Address: 131
Type: 5
Interval: 0

Weird that the Prolific detection doesn’t work, but great that it works now !