am trying to work out from your project code how to call to get data
can you post a code snippet?
thanks
I do see you have had to check on the type of data for the expected length etc
OK, the thing is that you don't call anything to get data, you
get called to receive data. The callback function
Handle_IOHIDDeviceInputReportCallback is there for that. Easiest thing to do is move that function to your own code and just leave an external declaration of it in hiddevice.c. After calling
Setup_HIDManager, data should start to come in.
Data is packed in a "report", where the first byte tells how many of the consecutive bytes are valid data. It's usually 1 byte for each report (at least for Oregon stuff), but you shouldn't rely on it. This example is in Objective-C, but you'll get the point on how to extract valid bytes and assemble data:
https://github.com/ejeklint/Cloudya/blob/master/daemon/WMR100NDeviceController.m#L136An alternative solution that makes assumptions of package lengths for assembling a complete data package from Oregon stations, which I just wrote in JavaScript for node.js, is this:
WMR100Controller.prototype.weatherData = function (error, data) { // "data" is the buffer with the Device Input Report
if (ffs === 2) { // ffs is a counter
// Two consecutive 0xff is detected, we are in sync! Start saving data until next two 0xff
for (var i = 0; i < data[0]; i++)
inbuf[ii++] = data[1 + i]; // Keep saving valid bytes in a buffer
// Check expected lengths. We know what from looking at the second byte after the sync-ffs.
if (expectedLength === 0 && ii > 5) {
switch (inbuf[1]) {
case 0x41:
expectedLength = 17;
break;
case 0x42:
expectedLength = 12;
break;
case 0x46:
expectedLength = 8;
break;
case 0x47:
expectedLength = 6;
break;
case 0x48:
expectedLength = 11;
break;
case 0x60:
expectedLength = 12;
break;
default:
// Unknown. Trash it and start looking for new frame
ii = ffs = expectedLength = 0;
}
}
if (ii === expectedLength) {
// Complete reading from weather station is acquired, toss it on!
this.emit('sensor' + inbuf[1].toString(16), inbuf.slice(0, expectedLength));
// Start looking for new frame
ii = ffs = expectedLength = 0;
}
} else if (ffs === 1 && data[1] !== 0xff) {
ffs = 0;
} else if (data[1] === 0xff) {
ffs++;
}
// Re-bind this callback to node-hid module
this.hid.read(this.weatherData.bind(this));
}
HTH.