Phidgets GPS Causing code to exit unexpectedly.

General PhidgetSBC Discussion.
RichardWright
Phidgetsian
Posts: 10
Joined: Wed Jan 19, 2011 7:17 am
Contact:

Phidgets GPS Causing code to exit unexpectedly.

Postby RichardWright » Tue Apr 12, 2011 4:00 am

Hi

I am have a system where by i use the 1048 (temperature) sensor to monitor some equipment and then send a message via a 232 Port as well as blink some LED's using interface kit, should the exceed given parameters. This all worked fine.

I have been trying to include the Gps module as well but it seems that when ever i have any other Phidget device open at the same time the GPS starts to give the following:
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
and also just randomly exits the program with out any errors/warnings.

If i do not open the interface& temperature kits the code runs fine or if i leave the GPS disconnected the code works fine.

I am currently running version 1.0.4.?? have tried various snapshot there of.

I have also tried changing the code to be event driven as well as linear but both seem to have similar results?

Does any one have and other suggestions or ideas as what i could try to resolve this problem?

Thanks

User avatar
Patrick
Lead Developer
Posts: 3100
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby Patrick » Tue Apr 12, 2011 9:12 am

What kind of computer are you using? This would happen is the computer is not polling the GPS often enough and missing chunks of the data. This could be caused by the computer being very busy, very slow, or doing too many things in the GPS position change handler.

-Patrick

User avatar
Patrick
Lead Developer
Posts: 3100
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby Patrick » Tue Apr 12, 2011 9:14 am

Oh I guess this is in the SBC thread so you're probably using an SBC.

Is your code running directly on the SBC? Check to see if your position change handler could be simpler. Also have a look at the system log for any USB related messages.

-Patrick

RichardWright
Phidgetsian
Posts: 10
Joined: Wed Jan 19, 2011 7:17 am
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby RichardWright » Mon Apr 18, 2011 9:18 am

Hi Patrick

Sorry for my misleading Question.

Yes my code is running directly on the SBC.
I have tried the Position change handler but the code still seems to exit. this was how ever while still polling the other Phidget devices. Trying to avoid using the OnChange Event handlers.

I am sadly not going be close to the system for the next 2 weeks or so, and will only be able to check the logs then. I will let you know what i find. Will also try changing code to all use OnChange handlers.

Thanks Richard

bartaaa404
Phidgetsian
Posts: 5
Joined: Sat Nov 03, 2012 11:07 am
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby bartaaa404 » Sat Jul 06, 2013 3:50 pm

Hi guys,

I'm having the exact same issue with the GPS module. Here is my error log:

Code: Select all

INFO: Enabling logging
INFO: New device in CUSBBuildList: 001006
INFO: New device in CUSBBuildList: 001005
WARN: usb_get_driver_np failed with error code: -61 "No data available"
INFO: Using Control Endpoint for Host->Device communication.
VERBOSE: usb_interrupt_read timeout: -110 "Connection timed out"
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
INFO: ReadThread running
INFO: WriteThread running
WARN: usb_get_driver_np failed with error code: -61 "No data available"
INFO: Using Control Endpoint for Host->Device communication.
INFO: ReadThread running
INFO: WriteThread running
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.


Then it exits spontaneously. I tried using GDB and I get the following messages:

Code: Select all

Starting program: ...
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
2013-07-06 21:44:14.766 Drone[6750] Initialize Hardware
INFO: Enabling logging
[New Thread 0xb4958460 (LWP 6753)]
INFO: New device in CUSBBuildList: 001006
INFO: New device in CUSBBuildList: 001005
WARN: usb_get_driver_np failed with error code: -61 "No data available"
INFO: Using Control Endpoint for Host->Device communication.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
[New Thread 0xb4158460 (LWP 6754)]
INFO: WriteThread running
[New Thread 0xb392c460 (LWP 6755)]
INFO: ReadThread running
WARN: usb_get_driver_np failed with error code: -61 "No data available"
INFO: SkyTraq ACK: 0x00
INFO: SkyTraq ACK: 0x37
INFO: Using Control Endpoint for Host->Device communication.
[New Thread 0xb312c460 (LWP 6756)]
INFO: WriteThread running
[New Thread 0xb292c460 (LWP 6757)]
INFO: ReadThread running
[New Thread 0xb1fff460 (LWP 6758)]
2013-07-06 21:44:38.022 Drone[6750] Drone Started!
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.
WARN: CRC Error parsing NMEA sentence.
WARN: Error parsing NMEA sentence.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb392c460 (LWP 6755)]
0xb6587e68 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6


Please note, the big difference between myself and the original poster of this thread is that I am currently running this code on a 'Raspberry Pi' Model B.

I hope you guys can help shine some light on this issue.

Thanks!

Addendum:
Please note, I receive this error when I use the 'Pidgets Hub' and have two devices connected to it: the GPS reader and Spatial Reader. However! If I directly connect the gps reader and the spatial reader to the two usb inputs for the raspberry pi, I do NOT receive the above mentioned error. Could this error thus be produced by the 'phidgets hub' ?

User avatar
Patrick
Lead Developer
Posts: 3100
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby Patrick » Mon Jul 08, 2013 8:22 am

The Raspberry Pi only puts out 100 mA - much less then a normal USB port, so you are probably having power issues. I would suggest using a powered hub.

-Patrick

rayui
Phidgetly
Posts: 19
Joined: Wed Jul 31, 2013 6:07 pm
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby rayui » Wed Jul 31, 2013 6:43 pm

Hi, I'm also running on a Raspberry Pi model B. I'm using a powered hub for the Phidgets and I get the same error message, followed by a crash. The log is here: http://pastebin.com/baLHtj8b. The web server seems stable and doesn't generate the NMEA errors when only the GPS or the Spatial is plugged in. I get the error message when both are connected.

I tested the generic C examples and they are stable. Given this and the above, is it less likely to be a power problem and more likely to be a problem with the web server?

They're otherwise great, by the way! Thanks!

rayui
Phidgetly
Posts: 19
Joined: Wed Jul 31, 2013 6:07 pm
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby rayui » Thu Aug 15, 2013 3:18 am

Okay, I've figured out what my problem is. Hopefully it will apply to RichardWright and bartaaa04, also. The issue seems to be in cphidgetgps.c. The library will segfault when attempting to parse an incomplete GPS message. I have fixed this by checking the GPS data to ensure it contains the checksum at the end of the message and dumps it if not, ensuring the parsing algorithm cannot then try to perform a read operation which will result in an out-of-bounds array access. I will post a patch for this later tonight. I don't think it's a very good fix (because I don't get incomplete GPS messages when only one Phidget is connected) but it does at least ensure that the library will not segfault every time it receives a bad message. To me, this smells like a buffer resource is shared between listener threads somewhere...

rayui
Phidgetly
Posts: 19
Joined: Wed Jul 31, 2013 6:07 pm
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby rayui » Thu Aug 15, 2013 2:38 pm

I made a patch for cphidgetgps.c. You can download it here: http://pastebin.com/M0ZfFDy5. As stated before, this doesn't fix the problem of incomplete GPS messages, it just stops the phidget library from segfaulting when it tries to parse one.

rayui
Phidgetly
Posts: 19
Joined: Wed Jul 31, 2013 6:07 pm
Contact:

Re: Phidgets GPS Causing code to exit unexpectedly.

Postby rayui » Thu Aug 15, 2013 3:46 pm

There is a further problem that some of the message parsing functions in cphidgetgps.c assume fields to be of greater than 0 length. I'm working on fixing this soon, too.


Return to “General”

Who is online

Users browsing this forum: No registered users and 0 guests