Esempio n. 1
0
 public void Open()
 {
     if (api.candle_dev_open(handle) == 0)
     {
         throw new CANableException("Failed to open device", api.candle_dev_last_error(handle));
     }
     opened = true;
 }
Esempio n. 2
0
        public unsafe void WriteExtendedFrame(Span <byte> data, uint id, bool rtr = false)
        {
            if (data.Length > 8)
            {
                throw new ArgumentOutOfRangeException(nameof(data), "Must be 8 bytes or less");
            }
            Frame frame;

            id          &= 0x1FFFFFFF;
            frame.CanDLC = (byte)data.Length;
            frame.CanId  = id | (uint)IdMasks.Extended;
            frame.CanId |= (rtr ? (uint)IdMasks.RTR : 0);
            if (api.candle_frame_send(device, channelNum, &frame) == 0)
            {
                throw new CANableException("Error Sending Frame", api.candle_dev_last_error(device));
            }
        }