tdSensor returning strange values

Moderator: Telldus

Post Reply
dagalufh
Posts: 12
Joined: Fri Mar 17, 2023 9:45 am

tdSensor returning strange values

Post by dagalufh »

Hi

I'm having issues with tdSensor() and tdSensorvalues()

I'm running this on NodeJS using FFI to call the C functions. The computer this is run on is running Telldus Center 2.1.2.

Code: Select all

Definitions of tdSensor and tdSensorvalue:
		tdSensor: ['int',['char*','int','char*','int','int*','int*']],
		tdSensorValue: ['int',['char*','char*','int','int','char*','int','int*']]
Code i run:

Code: Select all


var protocolPtr = ref.alloc('char');
var modelPtr = ref.alloc('char');
var datatypePtr = ref.alloc('int');
var idPtr = ref.alloc('int');

while (variables.telldus.tdSensor(protocolPtr,20,modelPtr,20,idPtr,datatypePtr) == 0) {
	
	console.log("success");
	console.log(protocolPtr.deref());
	console.log(modelPtr.deref());
	console.log(idPtr.deref());
	console.log(datatypePtr.deref());
	
	var valuePtr = ref.alloc('char');
	var timePtr = ref.alloc('int');
	
p = variables.telldus.tdSensorValue(protocolPtr,modelPtr,idPtr.deref(),datatypePtr.deref(),valuePtr,32,timePtr);
console.log("Result: " + p);
	
};
This is the output:

Code: Select all

102
116
135
3
Result: -4

102
116
135
1
Result: -4

If i register a callback to tdRegisterSensorEvent(), i get the following in return:

Code: Select all

Received an event on sensor with id(135) that reported value: 4.7
fineoffset : temperaturehumidity : 135 : 1 : 4.7 : 1486064027
Received an event on sensor with id(135) that reported value: 59
fineoffset : temperaturehumidity : 135 : 2 : 59 : 1486064027
So, why does tdSensor return 102 as protocol, 116 as model? while the tdRegisterSensorEvent() returns fineoffset as protocol and temperaturehumiditiy as model?

Hopefully someone can spot the issue and help me resolve it.
Thanks in advance
Post Reply