Storing Negative Numbers

Started by rubberchicken, September 07, 2015, 07:57:50 PM

rubberchicken

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

Felix

Good catch, negatives have to be supported. I will look at this soon. That should perhaps be a buff.writeInt32BE(value,5);


Felix

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.