Пример #1
0
        private static async Task <IEnumerable <uint> > DiscoverDevices(SMBusInterface connection)
        {
            var addresses = new List <uint>();

            for (byte addr = 11; addr < 12; addr++)
            {
                try
                {
                    var response = await connection.ReadWordCommand(addr, 0x09);

                    if (response == 0)
                    {
                        continue;
                    }
                }
                catch (AggregateException ex)
                {
                    if (ex.InnerException is InvalidOperationException)
                    {
                        continue;
                    }

                    throw;
                }

                addresses.Add(addr);
            }

            return(addresses);
        }
Пример #2
0
        private static void TestAllCommands(SMBusInterface connection, byte address)
        {
            connection.QuickCommand(address);
            //connection.SendByte(address, 0x79);
            connection.WriteByteCommand(address, 0x01, 0x79);
            connection.WriteWordCommand(address, 0x02, 0x4567);
            connection.WriteBlockCommand(address, 0x03, new byte[] { 0x12, 0x34, 0x56, 0x78 });

            //byte tmpData = connection.ReceiveByte(address);
            byte   byteData = connection.ReadByteCommand(address, 0x04).Result;
            ushort wordData = connection.ReadWordCommand(address, 0x05).Result;

            byte[] blockData = connection.ReadBlockCommand(address, 0x06, 4).Result;
        }