public unsafe bool Init(uint type, uint ind, uint canid, uint baud) { try { if (CANDLL.CXCAN.VCI_OpenDevice(type, ind, canid) != STATUS_OK) { IsStart = false; return(false); } if (CANDLL.CXCAN.VCI_SetReference(type, ind, canid, 0, (byte *)&baud) != STATUS_OK) { IsStart = false; return(false); } int nTimeOut = 3000; CANDLL.CXCAN.VCI_SetReference(type, ind, canid, 4, (byte *)&nTimeOut); VCI_INIT_CONFIG config = new VCI_INIT_CONFIG(); config.AccCode = Convert.ToUInt32(0x00000000); config.AccMask = Convert.ToUInt32(0xFFFFFFFF); config.Filter = 0x01; config.Mode = 0x00; if (CANDLL.CXCAN.VCI_InitCAN(type, ind, canid, ref config) != STATUS_OK) { IsStart = false; return(false); } _device = type; _ind = ind; _id = canid; _baud = baud; if (IsStart = StartCAN()) { _dataPicker.Start(); return(true); } } catch (Exception e) { IsStart = false; return(false); } return(false); }
internal static extern UInt32 VCI_InitCAN(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_INIT_CONFIG pInitConfig);