LowPowerLab Forum

Software support => Pi Gateway => Topic started by: rubberchicken on September 07, 2015, 07:57:50 PM

Title: Storing Negative Numbers
Post by: rubberchicken on September 07, 2015, 07:57:50 PM
Hi,

I am using the latest gateway image to log a pressure sensor that indicates both positive and negative numbers.

It appears that the new storage engine can only handle unsigned numbers, ie. buff.writeUInt32BE(value,5);

What would be the best way to work around this?

[08-09-15_09:34:51.458] [LOG] >: [31] V:3.42v TC:1260 P:-78 [RSSI:-91]                 
[08-09-15_09:34:51.462] [LOG] post: /home/pi/moteino/db/0031_V.bin[1441668891,3.42]
[08-09-15_09:34:51.465] [LOG] post: /home/pi/moteino/db/0031_C.bin[1441668891,1260]
[08-09-15_09:34:51.467] [LOG] post: /home/pi/moteino/db/0031_P.bin[1441668891,-78]
[08-09-15_09:34:51.469] [LOG]     POST ERROR: value is out of bounds

Cheers,
RC
Title: Re: Storing Negative Numbers
Post by: Felix on September 07, 2015, 10:03:31 PM
Good catch, negatives have to be supported. I will look at this soon. That should perhaps be a buff.writeInt32BE(value,5);
Title: Re: Storing Negative Numbers
Post by: rubberchicken on September 07, 2015, 10:46:48 PM
Thanks Felix
Title: Re: Storing Negative Numbers
Post by: Felix on September 22, 2015, 03:48:31 PM
Ok so the problem is one line in logUtil.js, in function post():

buff.writeUInt32BE(value,5);     //value 4 bytes

needs to be:

buff.writeInt32BE(value,5);     //value 4 bytes

This will be fixed with a new release.
Title: Re: Storing Negative Numbers
Post by: rubberchicken on September 22, 2015, 07:16:39 PM
Thanks Felix