public bool SendMessage(Message message) { ECAN.CAN_OBJ obj = new ECAN.CAN_OBJ(); obj.ID = (uint)message.Id; obj.TimeStamp = 0; obj.TimeFlag = 0; obj.SendType = 0; obj.RemoteFlag = 0; obj.ExternFlag = 0; obj.DataLen = 8; obj.Data = new byte[8]; message.Data.CopyTo(obj.Data, 0); obj.Reserved = new byte[8]; for (int i = 0; i < 3; i++) { obj.Reserved[i] = 0; } bool ret = UsbCanUtil.Instance().Send(ref obj); return(ret); }
public static bool OpenCan() { ECAN.INIT_CONFIG initConfig = new ECAN.INIT_CONFIG(); initConfig.AccCode = UsbCanUtil.CalculateStandardFrameAccCode((uint)DcmService.ResponseId); initConfig.AccMask = 0x0; initConfig.Reserved = 0x0; initConfig.Filter = 0x00; initConfig.Timing0 = 0x0; initConfig.Timing1 = 0x1c; initConfig.Mode = 0x00; return(UsbCanUtil.Instance().Open(UsbCanUtil.DefaultDeviceType, ref initConfig)); }
public Message ReceiveMessage(int timeout) { ECAN.CAN_OBJ obj; var ok = UsbCanUtil.Instance().Receive(out obj, (uint)timeout); if (!ok) { return(null); } else { Message message = new Message(); message.Id = (int)obj.ID; message.DataLen = obj.DataLen; obj.Data.CopyTo(message.Data, 0); return(message); } }
public static bool CanIsOpened() { return(UsbCanUtil.Instance().IsOpened); }
public static void CloseCan() { UsbCanUtil.Instance().Close(); }