Ejemplo n.º 1
0
        private IFirmataMessage CreateI2CReply(MessageHeader messageHeader)
        {
            var reply = new I2CReply
            {
                Address  = messageHeader.MessageBuffer[2] | (messageHeader.MessageBuffer[3] << 7),
                Register = messageHeader.MessageBuffer[4] | (messageHeader.MessageBuffer[5] << 7)
            };

            var data = new byte[(messageHeader.MessageBufferIndex - 5) / 2];

            for (int x = 0; x < data.Length; x++)
            {
                data[x] = (byte)(messageHeader.MessageBuffer[x * 2 + 6] | messageHeader.MessageBuffer[x * 2 + 7] << 7);
            }

            reply.Data = data;

            //if (I2CReplyReceived != null)
            //    I2CReplyReceived(this, new I2CEventArgs(reply));
            messageHeader._arduinoSession.EvintI2C().OnI2CReplyReceived(new I2CEventArgs(reply));

            return(new FirmataMessage <I2CReply>(reply));
        }
Ejemplo n.º 2
0
 internal I2CEventArgs(I2CReply value)
 {
     Value = value;
 }