public static bool Mid_API_Serial_Open(uint ComPort) { //Mod by FJ for fix linking to incorrect Dll API issue, 2016-12-23 bool result = false; //bool result = true; rfid.Linkage lk = new rfid.Linkage(); uint[] DetectBaudRate = new uint[] { (uint)ENUM_BAUD_RATE.CBR_115200, (uint)ENUM_BAUD_RATE.CBR_230400, (uint)ENUM_BAUD_RATE.CBR_460800, (uint)ENUM_BAUD_RATE.CBR_921600 }; uint errcount = 0; for (int i = 0; i < DetectBaudRate.Length; i++) { if (FTDI_API_Serial_Open(DetectBaudRate[i], ref ftHandle) == FTDI.FT_STATUS.FT_OK) { Use_FTDI_Dll = true; if (lk.API_MacgGetDebug(ref errcount) != Result.OK) { result = false; continue; } else { result = true; return(result); } } else { result = false; } } if (result == false) { Use_FTDI_Dll = false; rfid.DCB pDcb = new rfid.DCB(); pDcb.ByteSize = 8; pDcb.Parity = 0; pDcb.StopBits = (byte)ENUM_STOP_BIT.ONESTOPBIT; pDcb.BaudRate = (uint)ENUM_BAUD_RATE.CBR_115200; if (clsPacket.TRANS_API_Serial_Open(ComPort, ref pDcb) != TRANS_RESULT.OK) { result = false; } else { result = true; } } ////Open COM port by WDK DLL ////Try to open real COM port by baudrate 115200 //Use_FTDI_Dll = false; //rfid.DCB pDcb = new rfid.DCB(); //pDcb.ByteSize = 8; //pDcb.Parity = 0; //pDcb.StopBits = (byte)ENUM_STOP_BIT.ONESTOPBIT; //pDcb.BaudRate = (uint)ENUM_BAUD_RATE.CBR_115200; //if (clsPacket.TRANS_API_Serial_Open(ComPort, ref pDcb) != TRANS_RESULT.OK) //{ // result = false; //} ////Open COM port by FTDI DLL //if (result == false) //Try to open virtual COM port by high speed baudrate //{ // uint[] DetectBaudRate = new uint[] { (uint)ENUM_BAUD_RATE.CBR_115200, (uint)ENUM_BAUD_RATE.CBR_230400, (uint)ENUM_BAUD_RATE.CBR_460800, (uint)ENUM_BAUD_RATE.CBR_921600 }; // uint errcount = 0; // //Use_FTDI_Dll = true; //Del by FJ for the FWUpdate failure in USB connection, 2016-09-08 // for (int i = 0; i < DetectBaudRate.Length; i++) // { // if (FTDI_API_Serial_Open(DetectBaudRate[i], ref ftHandle) == FTDI.FT_STATUS.FT_OK) // { // if (lk.API_MacgGetDebug(ref errcount) != Result.OK) // { // result = false; // continue; // } // else // { // Use_FTDI_Dll = true; //Add by FJ for the FWUpdate failure in USB connection, 2016-09-08 // result = true; // break; // } // } // else // { // result = false; // } // } //} //End by FJ for fix linking to incorrect Dll API issue, 2016-12-23 return(result); }