static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCANV2 can = new BrickletCANV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Configure transceiver for loopback mode can.SetTransceiverConfiguration(1000000, 625, BrickletCANV2.TRANSCEIVER_MODE_LOOPBACK); // Register frame read callback to function FrameReadCB can.FrameReadCallback += FrameReadCB; // Enable frame read callback can.SetFrameReadCallbackConfiguration(true); // Write standard data frame with identifier 1742 and 3 bytes of data can.WriteFrame(BrickletCANV2.FRAME_TYPE_STANDARD_DATA, 1742, new byte[] { 42, 23, 17 }); Console.WriteLine("Press enter to exit"); Console.ReadLine(); can.SetFrameReadCallbackConfiguration(false); ipcon.Disconnect(); }
public bool WriteMessage(CanPackage package) => _canBricklet.WriteFrame((byte)package.Type, package.Identifier, package.GetData());