Пример #1
0
 public bool Connect()
 {
     if (!IsOpen)
     {
         IsOpen = VCI_OpenDevice(DevType, DevIndex, CanIndex) != 0;
         VCI_ERR_INFO pErrInfo = new VCI_ERR_INFO();
         VCI_ReadErrInfo(DevType, DevIndex, CanIndex, ref pErrInfo);
         if (IsOpen)
         {
             VCI_INIT_CONFIG config = new VCI_INIT_CONFIG();
             config.AccCode = 0x00;
             config.AccMask = System.Convert.ToUInt32("0xFFFFFFFF", 16);
             config.Timing0 = 0x00;
             config.Timing1 = 0x1c;
             config.Filter  = 0x01;
             config.Mode    = 0x00;
             VCI_InitCAN(DevType, DevIndex, CanIndex, ref config);
             VCI_StartCAN(DevType, DevIndex, CanIndex);
             VCI_BOARD_INFO br = new VCI_BOARD_INFO();
             VCI_ReadBoardInfo(DevType, DevIndex, ref br);
             if (rec_work_thread == null)
             {
                 rec_work_thread = new Thread(RecWorkThread);
                 rec_work_thread.Start();
             }
         }
         else
         {
             Console.WriteLine("Can卡初始化失败!");
         }
     }
     return(IsOpen);
 }
Пример #2
0
 static extern UInt32 VCI_ReadErrInfo(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_ERR_INFO pErrInfo);