Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program stuck on ubr.read() #8

Closed
vikram223 opened this issue Jan 15, 2021 · 4 comments
Closed

Program stuck on ubr.read() #8

vikram223 opened this issue Jan 15, 2021 · 4 comments
Assignees
Labels
expected behaviour Working as expected

Comments

@vikram223
Copy link

vikram223 commented Jan 15, 2021

Environment MACOS Catalina, Anaconda, Spyder:
Python version 3.8.1
Code:

import serial
from pyubx2 import UBXReader

stream = serial.Serial('/dev/tty.usbmodem142301',38400)  # open serial port
ubr = UBXReader(stream)
print(ubr.read())
stream.close()

Program hangs on ubr.read().
Attempted to change baudrate etc.

Can confirm that the standard stream.read() and stream.readline() functions output the data correctly

@semuadmin
Copy link
Contributor

semuadmin commented Jan 16, 2021

Hi - could I ask you to take a look at the bug report template and fill in as much detail as you can on the problem you're having, including the UBX device type, version of pyubx2 you're using and if possible a binary dump of the input stream. Many thanks.

https://github.com/semuconsulting/pyubx2/blob/master/.github/ISSUE_TEMPLATE/bug_report.md

Also, can you confirm what happens if you instantiate the UBXReader class with the validate flag set to true? i.e.

ubr = UBXReader(stream, True)

If you have an input stream which contains nothing but NMEA data (no UBX data) and you have the validate flag set to 'False' (the default), then - yes - the read() function will block until it receives a UBX data packet. This is expected behaviour. The resolution is either to:

a) ensure that your input stream includes UBX data by setting the message rates appropriately (e.g. set CFG_MSGOUT_UBX_NAV_PVT_UART1 to 1 using the CFG-VALSET command, if it's a G9 device),
b) set the validate flag to 'True', in which case the read() function should output a UBXStreamError if it encounters non-UBX data - e.g.:

pyubx2.exceptions.UBXStreamError: Unknown data header b'$G'. Looks like NMEA data. Set validate to 'False' to ignore.

@semuadmin
Copy link
Contributor

Also, have you tried running the ubxstreamer.py example in the /examples folder? This should poll the device's UBX message rates and respond with a series of CFG-MSG responses.

@semuadmin semuadmin self-assigned this Jan 16, 2021
@semuadmin semuadmin added the question Further information is requested label Jan 16, 2021
@vikram223
Copy link
Author

Apologies, I had the validate flag set to false. I thought I tested it with both values for the validate flag, but I must've made a mistake. You're right, my data output is only nmea stream. I am getting UBX messages when I save the ubx file using u-center but I'm not seeing it directly from the serial port I guess.

I will try the ubxsteamer.py today. Thanks a lot fr the support. Please go ahead and close the issue.

@semuadmin
Copy link
Contributor

semuadmin commented Jan 16, 2021

No worries. FYI you might want to check out PyGPSClient, a cross-platform GUI application which uses pyubx2 and provides some of the u-center functionality. https://pypi.org/project/PyGPSClient/

@semuadmin semuadmin added expected behaviour Working as expected and removed question Further information is requested labels Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expected behaviour Working as expected
Projects
None yet
Development

No branches or pull requests

2 participants