I am working on a customized version of Ardurover (from the 3.0.1 version). I added libraries to handle my own communication protocol and modified others (like AP_Mission) and I come here because I have a very weird issue.
As information, I work with Eclipse environment from the PX4 toolchain.
My problem is as follow :
In AP_Mission, I added a variable mission_id. This id is saved in the EEPROM and is loaded in a private variable _mission_id.
-A new library AP_Modem checks the available bytes from my radio : it counts how many bytes have been received with _nb_byte_received.
Up until now, _mission_id was 1-byte long (type uint8_t) and everything was working fine.
I want it to be 4-byte long and so I changed the type from uint8_t to uint32_t. The consequence (as far as I have diagnosed) is that the variable _nb_byte_received is resetted without reason (no calls are made to the existing functions of reset).
After searching, reversing and redoing everychange one by one. The only change that generates this weird reset is changing the type of _mission_id from uint8_t to uint_32.
So I come here to find some explanations if there is or some advise on what to check.
I’d like to check the memory usage but I don’t know how.
You are in a hairy part of the code. If you look at the “union PACKED Content” you will see its a fixed size of 12 bytes. Once you send lat, long and alt (the Location struct in AP_Common) each being 4 bytes then you have no space left for anything else. In other words the NAV_WP command is already full - you can’t send any extra data.
You do have access to p1 - the general purpose parameter in the Mission_Command but that’s already used for loiter time in Rover in the NAV_WP command.
Now we do cheat slightly. If you look in AP_Common.h you will see “struct PACKED Location” specifies that alt is actually 24 bits instead of 32 like lat and long. This gives us 1 byte to send some flags in - see Locaiton_Option_Flags above.
So that’s my guess as to what’s causing your issue. Without seeing your code its the best I can do.
I have done a little more research and it appears that other modification can cause my problem (moving a parenthesis, adding a variable in an other class, changing my communication buffer sizes, and more). Therefore I think I have a global issue that limits the changes I can do…
Concerning the union PACKED content, I respected the format. The variable _mission_id is a new attribute of the AP_Mission class (like _last_change_time_ms).