/* OneWire READ reply * 0 START_SYSEX (0xF0) * 1 OneWire Command (0x73) * 2 read reply command (0x43) * 3 pin (0-127) * 4 bit 0-6 [optional] //data bytes encoded using 8 times 7 bit for 7 bytes of 8 bit * 5 bit 7-13 [optional] //correlationid[0] = byte[0] + byte[1]<<7 & 0x7F * 6 bit 14-20 [optional] //correlationid[1] = byte[1]>1 + byte[2]<<6 & 0x7F * 7 bit 21-27 [optional] //data[0] = byte[2]>2 + byte[3]<<5 & 0x7F * 8 .... //data[1] = byte[3]>3 + byte[4]<<4 & 0x7F * n ... // as many bytes as needed (don't exceed MAX_DATA_BYTES though) * n+1 END_SYSEX (0xF7) */ public static OneWireReadReply ParseReadReply(int[] messageBuffer, int messageBufferIndex) { var reply = new OneWireReadReply { Bus = messageBuffer[2] }; var dataBytes = messageBuffer.Skip(4).Take(messageBufferIndex - 4).OfType<byte>().ToArray(); var bytesToDecode = 2 + 9; var decodedDataBytes = Encoder7BitClass.ReadBinary(bytesToDecode, dataBytes); reply.CorrelationByte1 = decodedDataBytes[1]; reply.CorrelationByte2 = decodedDataBytes[2]; return reply; }
public OneWireReplyReceivedEventArgs(OneWireReadReply readReply) { ReadReply = readReply; Type = OneWireReplyType.ReadReply; }