u-blox / ubxlib

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.
Apache License 2.0
287 stars 82 forks source link

how to enable multiple selected messageId.id.pNmea msg types #204

Closed mabroens closed 3 months ago

mabroens commented 4 months ago

Hi Rob,

i was looking for some more documentation to messageId.id.pNmea.

at the moment i have following:

messageId.type = U_GNSS_PROTOCOL_NMEA;
messageId.id.pNmea = "G?GGA";

but i would also like to have: messageId.id.pNmea = "G?RMC";

how can i enable this? pNmea is not a list type and messageId.id.pNmea = NULL;does not give me the G?RMC.

what is the best way to get only specific msg types?

Br Martijn

RobMeades commented 4 months ago

Hi Martijn: you could do this two ways:

(a) make another call to uGnssMsgReceiveStart() for "G?RMC" (don't worry about resources, internally it will use the same monitoring task as your "G?GGA" is already using) and either do a uGnssMsgReceiveStop() for both when done or just call uGnssMsgReceiveStopAll() which will stop both of them,

(b) you could set the filter to messageId.type = U_GNSS_PROTOCOL_NMEA; messageId.id.pNmea = ""; (i.e. all NMEA messages) and do the filtering yourself in your uGnssMsgReceiveCallback_t callback by checking the contents of the pMessageId pointer it is passed, e.g. with uGnssMsgIdIsWanted() in a loop for a list of wanted message IDs, or by hand in your own way if you prefer: this might be a very slightly higher processor load but, in the end, the filtering is always going to be in C code on the MCU and so whether you do it in your application or ubxlib does it is a moot point.

RobMeades commented 4 months ago

I have added this advice to master here, see https://github.com/u-blox/ubxlib/commit/9694ef9d70e6e7d90562174e8c4d52555d8730da.

RobMeades commented 4 months ago

Re-reading your original post:

pNmea is not a list type and messageId.id.pNmea = NULL; does not give me the G?RMC.

Setting messageId.id.pNmea = NULL, rather than messageId.id.pNmea = "", would cause the NMEA message type to be the first five characters of whatever "string" is at address 0 on your MCU, which would explain why you don't get "G?RMC"; I think we have this wrong either in the documentation [which says that setting pNmea to NULL will get all NMEA messages] or in the code, will go check...

!!! CORRECTION !!! setting messageId.id.pNmea to NULL should return all NMEA messages to you, i.e. you have effectively already done (b) above, and I can't see where this would go wrong. If possible, could you try compiling ubxlib with U_GNSS_PRIVATE_DEBUG_PARSING? This will bring into play the debug code just here which, with ubxlib default debug logging on, should tell us why "G?RMC" is being discarded when it should be that no NMEA messages at all are discarded.

RobMeades commented 3 months ago

Hi Martijn: did you resolve this issue or is there more to do?

mabroens commented 3 months ago

Hi Rob,

apologies forgot to close this one yes this helped me.

thanks for your assistance