-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Configuring receiver -> then UBXReader stops reading after several succesful readings (F9P) #11
Comments
Hi djdan7. Glad you're finding the library useful, but sorry to hear you're having problems. I notice in your code that you're instantiating the UBXReader object repeatedly within the read loop (and thereby creating 300 separate instances). This only needs to be done once at the head of the loop, i.e.
Suggest you try this change first and see if it resolves your problem. You could if you prefer also use the UBXReader iterator with a millisecond timer, rather than a fixed number of iterations. e.g. something like this (pseudocode):
Hope this helps. |
The UBXReader.read() method shouldn't have a problem with non-UBX (e.g. NMEA) data - provided the validate flag is set to the default 'False', it does effectively 'filter them out'. I don't have an F9P device to hand but I've run your modified code through a standard-precision device (using NAV-POSLLH rather than NAV-HPPOSLLH) at 10Hz and 921600 baud (nominal) and it seems to run fine the first time, but glitches after a few seconds on any subsequent run. If, however, I explicitly set the navBbrMask in CFG-RST to b'\x0000' (rather than 'b\x00\x00', which is what UBXMessage.read() defaults it to) the problem goes away and I can run the code repeatedly without difficulty. Suggest trying the following in the relevant sections in your code and see if it improves matters: If this works consistently, I may need to make a minor tweak to ubxmessage.py. This is the modified code that seems to work OK for me:
|
If I set navBbrMask it does not start nor stop receiver :/ PS. For what you do u-blox should send you a C099-F9P for free. Have you tried to contact them? |
I've set navBbrMask to b'\x0000' - it didn't work, so then I've copied all code, which you provided (and changed com port) - it also didn't work. What I mean saying didn't work:
I think that 'Controlled GNSS stop or start' =/= Hot start. When I stop GNSS for couple of minutes - it performs hot start, but when I stop it for i.e. 1 hour - it performs warm start, etc. So it not always performs hot start What a shame for the u-blox. A decent reading library for ubx (like yours) in Python makes people from non-IT fields (like me) interested in their product. I think Python is the only simple language for people outside the IT industry. I ordered it about 3 months ago and the package arrived after a week. |
OK leave it with me for now - I'll need to run some comparative tests against u-center to see exactly how u-center is populating the navBbrMask field in the CFG-RST GNSS stop/start message. |
Ok, thank you so much for your effort! |
OK I believe this is sorted now with a fix to UBXReader which I've just uploaded in v1.0.3. Basically, you called it in your original issue report but I managed to lead us down a wild goose chase with CFG-RST message formats - doh! The CFG-RST message handling was fine - the problem was in the parsing of the subsequent NMEA TXT responses. Surprised this hasn't cropped up before. I've rerun my modified version of your test code (with navBbrMask left at the default b'\x00\x00') and it seems to be working fine now. GNSS is successfully stopped at the end and I'm seeing no further UBX messages until I explicitly start it again. Have a go yourself and let me know if it works for you. |
Thank you! If I can spam a little more here, I'd have a question. What is the appropriate method to also read the NMEA message once every 10 seconds? I need to read a GNGGA message, so then I can send it to the NTRIP client and download the appropriate RTCM corrections. At this point, I wrote something like this, but I predict that it could be done a little better:
It works fine (I have everything I need), but it read NMEA messages at 10Hz unnecessarily. Would it be better to send a message every 10 seconds to configure the receiver to send GNGGA, then read this message and send the configuration message again so that it stops sending GNGGA? Do I need to use "UBX-CFG-VALSET"? I'm not 100% sure how to do it exactly. Thank you in advance! :D |
OK glad it works and sorry for the wild goose chase! You've also prompted me to make a corresponding change to the partner GUI application PyGPSClient. In terms of your use case, few observations that might help:
You might also like to check out PYGPSClient. It's not intended to be a u-center replacement but, unlike u-center, it runs on any platform and it provides a 'ubxpresets' facility allowing users to configure frequently-used message sequences (e.g. in your case a GNSS stop/start or a change in message rate). It also has a somewhat less daunting UI (IMHO!). Hope this helps. Thanks for picking this up. Are you OK for me to close this issue now? |
Thank you soooo much! :D Of course, you can close this issue :D |
Cheers. PS if you're liking the library, it would help me if you could 'Star' it in Github :-) |
Hi, firstly thank you very much for the great package regarding the issue of the stuck At first be aware that the
But I encounter the same problem with a F9P, when sending a The problem can be circumvented by sleeping for more than 0.1 seconds after writing to the device, but I think this is not so nice, and can be avoided by the proposed usage of a reading-thread. Best regards |
Hi - so firstly, yes I am aware that the CFG-RST message won't receive an acknowledgement. Indeed, it may result in a serial port 'ClearCommError' requiring a restart of the device port (I mention this explicitly in the CFG-RST example in my sample ubxpresets file). If you're implementing an application that sends CFG-RST messages frequently you could choose to handle this in a suitable try-except loop. On your second point, apologies but I'm not sure I understand the question. What particular CFG-VALSET message are you sending? Are you using the PyGPSClient UBXConfig facility or do you have some other sample code? In my examples the serial read thread is in effect an 'infinity loop' which is only terminated when you close the serial port, so I'm unclear in what sense this is not expected behaviour? |
Thanks for your fast reply Basically I would like to configure+read/poll ublox-gnss Receivers with a python script: class UbloxReceiver:
...
def _ubx_communicate(msg: UBXMessage, expect_ack: bool, expect_msg: bool, timeout: float) -> typing.Union[UBXMessage, bool]:
...
if msg.msgmode != GET:
self._serial_object.write(msg.serialize())
time.sleep(0.5) # workaround
while check_timeout is False:
try:
(_, parsed_data) = self._ubxreader.read():
....
if parsed_data.identity == msg.identity and expect_msg:
return parsed_data
if
except ...
return False Right now I do not use a reading-thread, but I would like to use one, as it clearly seems to be more stable, than my current approach. My Question would be: |
Hi Nerolf05 - sorry for the delay in getting back to you. I think this is more a general Python thread-handling question than a specific pyubx2 issue, but if I understand your requirement correctly, you want to send commands to the device while at the same time monitoring the output. That's basically exactly what the '\examples\ubxstreamer.py' example does, so I recommend you take a look at that. Alternatively, if you want a more sophisticated example you could take a look at the implementation in the PyGPSClient GUI application (specifically the 'serial_handler.py' and 'ubx_handler.py' modules). I'm closing this issue thread down now, but I hope this helps, and thanks again for your interest in the pyubx2 library. |
Firstly I want to thank you for the effort you put into creating this library - it's AWESOME and you are GREAT! :D
My config:
u-blox C099-F9P // FWVER = HPG 1.13 // PROTVER = 27.12
navigation frequency: 10Hz
connection via USB cable (UART1)
windows 10 x64
python 3.7.9
pyubx2 ver. 1.0.2
My problem:
I want to start GNSS (via CFG-RST message), then read UBX messages for some time (in my case these are MON-RF, NAV-DOP, NAV-EELL, NAV-HPPOSLLH, NAV-PVT, NAV-SIG, NAV-STATUS) and stop GNSS (again via CFG-RST). The reason why I want to stop and start GNSS is that I want to save battery while keeping GNSS parameters in memory (so then I may perform hotstart).
How my code below works:
#receiver is stopped
-Starting GNSS is succesfull
-Reading several first message is also succesful, but then it hangs up and wait for message from serial (but the receiver is still working, and the serial send messages)
-I terminate the script
#start again (now the receiver keeps working - we are not stopped it)
-"Starting" GNSS is succesful - it just sends the message, but of course receiver is already wroking
-Reading all messages is succesfull
-Stopping GNSS is succesful
#again receiver is stopped
-Starting GNSS is succesfull
-Reading several first message is also succesful, but then it hangs up...
...
I tried to set validate flag to True - it raise
What I noticed - after several OK readings it starts to divide binary message to single bytes and this is why this error occurs.
To prevent this I need to close port after writing, sleep for 1 second (shorter values don't help), open serial port again and flush it. This way everything works OK. But the problem is that in the future I would like to configure receiver on the run and then 1 second break looks ugly :/
Code:
The text was updated successfully, but these errors were encountered: