Fix bug on radiosonde Meteoman Lat & lon calculation

The underlying function used for calculating Latitude and Longitude -also used in other places inside the radiosonde app- was returning a positive value always.

But it needs to cope with negative values also (i.e. Lat and Lon)

Fixed by just changing the returning value into int32_t (even if the calculation is done in uint32_t, the actual sign is passed thru when returning the calculated value -those are the same 4 bytes, interpreted either as (before) unsigned or (now) signed)
This commit is contained in:
euquiq 2021-01-25 23:41:19 -03:00
parent 608c8c3597
commit 50bab791dd

View File

@ -49,7 +49,7 @@ public:
/* The "start_bit" winds up being the MSB of the returned field value. */
/* The BitRemap functor determines which bits are read from the source
* packet. */
uint32_t read(const size_t start_bit, const size_t length) const {
int32_t read(const size_t start_bit, const size_t length) const { //Euquiq: was uint32_t, used for calculating lat / lon in radiosondes, can be negative too
uint32_t value = 0;
for(size_t i=start_bit; i<(start_bit + length); i++) {
value = (value << 1) | data[bit_remap(i)];