示例#1
0
        private bool OpenUsbCan()
        {
            if (ZLGBasic.VCI_OpenDevice(m_DevType, m_DevIndex, 0) != ZLGBasic.STATUS_ERR)
            {
                VCI_INIT_CONFIG Cfg = new VCI_INIT_CONFIG();

                Cfg.AccCode = 0x00000000; //验收码
                Cfg.AccMask = 0xFFFFFFFF; //验收屏蔽码
                Cfg.Filter  = 1;          //滤波方式 1: 单滤波 0: 双滤波
                Cfg.Mode    = 0;          //0:正常模式 1:只听模式
                Cfg.Timing0 = 0x00;       //通讯速率  1Mbps
                Cfg.Timing1 = 0x14;

                //判断CAN是否能初始化
                if (ZLGBasic.VCI_InitCAN(m_DevType, m_DevIndex, m_CanIndex, ref Cfg) == ZLGBasic.STATUS_OK)
                {
                    ZLGBasic.VCI_ClearBuffer(m_DevType, m_DevIndex, m_CanIndex);

                    return(ZLGBasic.VCI_StartCAN(m_DevType, m_DevIndex, m_CanIndex) == ZLGBasic.STATUS_OK);
                }
            }

            return(false);
        }
示例#2
0
 public static extern UInt32 VCI_InitCAN(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_INIT_CONFIG pInitConfig);//初始化CAN