static async Task Main(string[] args) { System.Console.WriteLine("Hello World!"); var logger = new ConsoleLoggerProvider((s, level) => true, true).CreateLogger("test"); var driver = new BaosDriver("/dev/ttyAMA0", logger, new DataReceiver(logger)); await driver.Start(); //var desc = await driver.GetDatapointDescriptions(); logger.LogDebug($"GetDpValues..."); var data = await driver.GetDatapointValue(1, 1); logger.LogDebug($"GetDpValues...done"); logger.LogDebug($"setDpValue..."); var data1 = await driver.GetDatapointValue(2, 1); //var sendData = await driver.SetDatapointValue(1, new byte[] { 0x00 }); logger.LogDebug($"setDpValue...done"); System.Console.ReadLine(); await driver.Stop(); }
public void TestParseDatapointValues() { var byteArray = new byte[] { 0x68, 0x11, 0x11, 0x68, 0xF3, 0xF0, 0x85, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x10, 0x01, 0x01, 0x00, 0x02, 0x10, 0x01, 0x01, 0x92, 0x16 }; var frame = BaosFrame.FromByteArray(BaosFrameType.LongFrame, NullLogger.Instance, byteArray); var data = BaosDriver.ParseDatapointValues((LongFrame)frame).ToList(); Assert.Equal(2, data.Count); //dp 1 Assert.Equal(1, data[0].DatapointId); Assert.Equal(0x10, data[0].State); Assert.Equal(0x1, data[0].Length); Assert.Equal(1, data[0].Data.ToArray()[0]); //dp 2 Assert.Equal(2, data[1].DatapointId); Assert.Equal(0x10, data[1].State); Assert.Equal(0x1, data[1].Length); Assert.Equal(1, data[1].Data.ToArray()[0]); }
public KnxBaosDriver(IDriverContext driverContext) : base(driverContext) { _driver = new BaosDriver("/dev/ttyAMA0", DriverContext.Logger, this); }