madhead
12/16/2017, 1:05 AMgildor
12/16/2017, 3:03 AMolonho
12/16/2017, 11:19 AMmadhead
12/16/2017, 12:48 PMioctl
call: https://github.com/fablabnbg/airco2ntrold/blob/master/airco2ntrold.py#L56. Python doc says that if the last parameter is string (as in this case), then it is treated as a struct of bytes. So, looks like the intent was to send [0x00, 0xc4, 0xc6, 0xc0, 0x92, 0x40, 0x23, 0xdc, 0x96]
byte array into the device. Indeed it's true - checked with WireShark, the payload was exactrly it. Some of this values, like 0xC4
are greater that 128, so must be unsigned. So what I had to do in K/N is arr.map { it.toByte() }.toByteArray().refTo(0)
.
The second issue was reading from the device. Again, it expects an unsigned byte buffer, I used ByteArray(8)
, but to get "real" values in [0..255] range I had to do frame.map { it.toInt() and 0xFF }.toIntArray()
...madhead
12/16/2017, 12:49 PM