Exemplo n.º 1
0
        public void Initialize()
        {
            uint count  = 0;
            var  status = _device.GetNumberOfDevices(ref count);

            if (status != FTD2XX_NET.FTDI.FT_STATUS.FT_OK && count == 0)
            {
                throw new Exception("Device not found");
            }

            var description = new FTD2XX_NET.FTDI.FT_DEVICE_INFO_NODE[count];

            status = _device.GetDeviceList(description);

            if (status != FTD2XX_NET.FTDI.FT_STATUS.FT_OK)
            {
                throw new Exception("Failed to list Devices");
            }

            status = _device.OpenByDescription(description[0].Description);
            if (status != FTD2XX_NET.FTDI.FT_STATUS.FT_OK)
            {
                throw new Exception("Failed to open Device");
            }

            _thread      = new Thread(Loop);
            _thread.Name = "CAN Driver Loop";
            _thread.Start();
        }