private static async Task <RawMetaData> GetRawDeviceMetadata(BusDevice busDevice, Dictionary <string, RawKnxDeviceMetadata> pReadlist, int throttling = 300) { // Sanity Checks // Read 0x00 0x01, we are expecting a zero here per KNX Standard Byte[] ba = await busDevice.PropertyRead(0x00, 0x01); UInt16 ui = BitConverter.ToUInt16(ba, 0); Byte[] ba2 = await busDevice.PropertyRead(0x00, 0x02); string s = ASCIIEncoding.ASCII.GetString(ba2); RawMetaData rawData = new RawMetaData(RawMetaData.ReadListDefinition.Empty); rawData.ReadList = pReadlist; foreach (RawKnxDeviceMetadata kvp in rawData.ReadList.Values) { Thread.Sleep(throttling); kvp.TriedReading = true; try { Byte[] baValue = await busDevice.PropertyRead <byte[]>((Byte)kvp.ObjectId, (Byte)kvp.ValueId); kvp.ReadSuccessful = true; kvp.RawPropertyValue = baValue; } catch (Exception Ex) { Console.WriteLine(Ex.ToString()); kvp.ReadSuccessful = false; } } return(rawData); }
/// <summary> /// Basic ping function the check if the device is responding /// </summary> /// <param name="busDevice"></param> /// <returns></returns> public static async Task <bool> PingDevice(BusDevice busDevice) { try { Byte[] ba = await busDevice.PropertyRead(0x00, 0x01); UInt16 ui = BitConverter.ToUInt16(ba, 0); return(true); } catch { return(false); } }