-
Notifications
You must be signed in to change notification settings - Fork 85
Feature request: multi-valset #20
Comments
Hi Nathan, |
Hi Paul - This is a good feature to have. Do you think it would be best implemented with a new setVal that takes in a pointer to a val array and a length? I'm thinking something like:
Do you think users will need to pass more than 256 elements? I'm not sure I have a good use case so if you have a real-world scenario that can be shown in an example, that would be helpful. |
My real-world example is a little outdated now (I'll explain below) but here goes: I need to log a continuous stream of RAWX, SFRBX and TIM_TM2 messages to SD card so I can post-process them (PPK) using RTKLIB. The reason the above is outdated is that I've figured out that I can do the message enabling through the I2C port instead, leaving the UART port ACK-free! So, strictly, it doesn't matter if the messages are enabled one at a time. The ACKs come back via I2C and I don't need to worry about them. You can find a UART-only example here plus here. It uses my own sendUBX routine. The equivalent I2C example is here and here. This uses your sendCommand function. VALSET can only support a maximum of 64 Key+value pairs: Hopefully that's makes it (slightly) easier? Perhaps the most elegant way would be to define an array of key and value pairs where each pair is defined as a struct of the 32-bit key plus 8, 16, or 32 bit values? Maybe with a union thrown in for good measure? (But I have run into problems before when including 8-bit values in structs and unions. You end up with word alignment problems that can crash the M0 and you need to define everything as _ _ attribute _ _ ((packed)) !) Thanks! |
That makes sense. I suspect there will be plenty of users who will need to send a handful of configuration commands at startup. Better to pass a bulk of them than to do one at a time.
For my own notes: each key is 4 bytes, and each config value can be 1 to 8 bytes. That's 12*64=768 bytes worst case. I'm all for a struct with various byte sizes 1/2/4/8. Please have at it and let me know what you think is best. |
So... Like Issue #21 , I tried to do this with an overloaded function that would accept keyIDs plus 8, 16 or 32 bit values but ran into the same ambiguity problems. Instead I have defined 8, 16 and 32 bit versions of three new functions: newCfgValset, addCfgValset and sendCfgValset. You begin with a newCfgValset which initialises packetCfg with the class and ID etc and adds the first keyID and value to the payload. You can then add additional keyIDs with 8, 16 or 32 bit values using addCfgValset. Finally, you add one last keyID plus value using sendCfgValset and the 'multiValSet' packet is sent. If you only want to set one value, use setVal8, setVal16 or setVal32 (Issue #21 ). Usage example:
See PR #30 for the new code. Thanks! |
From other issue:
Hi Nathan ( @nseidle ),
Sincere thanks for sharing this library! I'm using it to talk to the ZED-F9P.
Can I please raise a "feature request"?
setVal() is great - but can only set one value at a time. Could you add an elegant way to set multiple keys in a single packet?
My inelegant way is to define them as a ubxPacket and send them using .sendI2cCommand :
// setRAWXon: this is the message which enables all of the messages to be logged to SD card in one go
// It also sets the NMEA high precision mode for the GNGGA message
// It also sets the main talker ID to 'GN'
// UBX-CFG-VALSET message with key IDs of:
// 0x209102a5 (CFG-MSGOUT-UBX_RXM_RAWX_UART1)
// 0x20910232 (CFG-MSGOUT-UBX_RXM_SFRBX_UART1)
// 0x20910179 (CFG-MSGOUT-UBX_TIM_TM2_UART1)
// 0x2091002a (CFG-MSGOUT-UBX_NAV_POSLLH_UART1)
// 0x20910007 (CFG-MSGOUT-UBX_NAV_PVT_UART1)
// 0x2091001b (CFG-MSGOUT-UBX_NAV_STATUS_UART1)
// 0x10930006 (CFG-NMEA-HIGHPREC)
// 0x209100bb (CFG-MSGOUT-NMEA_ID_GGA_UART1)
// and values (rates) of 1
// 0x20930031 (CFG-NMEA-MAINTALKERID) has value 3 (GN)
static uint8_t setRAWXon_payload[] = {
0x00, 0x01, 0x00, 0x00,
0xa5, 0x02, 0x91, 0x20, 0x01,
0x32, 0x02, 0x91, 0x20, 0x01,
0x79, 0x01, 0x91, 0x20, 0x01,
0x2a, 0x00, 0x91, 0x20, 0x00, // Change the last byte from 0x01 to 0x00 to leave NAV_POSLLH disabled
0x07, 0x00, 0x91, 0x20, 0x01, // Change the last byte from 0x01 to 0x00 to leave NAV_PVT disabled
0x1b, 0x00, 0x91, 0x20, 0x01, // This line enables the NAV_STATUS message
0x31, 0x00, 0x93, 0x20, 0x03, // This line sets the main talker ID to GN
0x06, 0x00, 0x93, 0x10, 0x01, // This sets the NMEA high precision mode
0xbb, 0x00, 0x91, 0x20, 0x01 }; // This (re)enables the GGA mesage
ubxPacket setRAWXon = { 0x06, 0x8a, 49, 0, 0, setRAWXon_payload, 0, 0, false };
Sincere thanks,
Paul
The text was updated successfully, but these errors were encountered: