public bool LinkDevice( ) { #if _TRACE_OUT_PUT PrintMagToTxt("LinkDevice"); #endif bool bGetUSB = false; do { //open USB foreach (ENUM_DEVICE_INFO device in Enum.GetValues(typeof(ENUM_DEVICE_INFO))) { if ( clsPacket.TRANS_API_USB_Open((uint)device, (uint)ENUM_DEVICE_INFO.MTI_VID) == TRANS_RESULT.OK ) { bGetUSB = true; break; } } if (bGetUSB) { #if _TRACE_OUT_PUT PrintMagToTxt("--Open USB successfully---"); #endif break; } else { #if _TRACE_OUT_PUT PrintMagToTxt("--Open USB fail---"); #endif } //open Serial rfid.DCB pDcb = new rfid.DCB(); pDcb.BaudRate = (uint)ENUM_BAUD_RATE.CBR_115200; pDcb.ByteSize = 8; pDcb.Parity = 0; pDcb.StopBits = (byte)ENUM_STOP_BIT.ONESTOPBIT; if (clsPacket.TRANS_API_Serial_Open(uiLibSettingComPort, ref pDcb) != TRANS_RESULT.OK) { #if _TRACE_OUT_PUT PrintMagToTxt("--Open Serial fail---"); #endif return false; } else { #if _TRACE_OUT_PUT PrintMagToTxt("--Open Serial successfully---"); #endif break; } }while( false ); //Set USB/RS232 Overlap time clsPacket.TRANS_API_SetOverlapTime( 200, 200 ); //Clear inventory's infomation buffer clsPacket.TRANS_API_ClearBuffer(); return true; }
private static extern TRANS_RESULT dllSerialOpen(uint uiComPort, ref DCB r_dcb);
public bool LinkDevice ( ) { #if _TRACE_OUT_PUT PrintMagToTxt("LinkDevice"); #endif bool bGetUSB = false; do { //open USB foreach (ENUM_DEVICE_INFO device in Enum.GetValues(typeof(ENUM_DEVICE_INFO))) { if ( clsPacket.TRANS_API_USB_Open((uint)device, (uint)ENUM_DEVICE_INFO.MTI_VID) == TRANS_RESULT.OK ) { bGetUSB = true; break; } } if (bGetUSB) { #if _TRACE_OUT_PUT PrintMagToTxt("--Open USB successfully---"); #endif break; } else { #if _TRACE_OUT_PUT PrintMagToTxt("--Open USB fail---"); #endif } //open Serial rfid.DCB pDcb = new rfid.DCB(); pDcb.BaudRate = (uint)ENUM_BAUD_RATE.CBR_115200; pDcb.ByteSize = 8; pDcb.Parity = 0; pDcb.StopBits = (byte)ENUM_STOP_BIT.ONESTOPBIT; if (clsPacket.TRANS_API_Serial_Open(uiLibSettingComPort, ref pDcb) != TRANS_RESULT.OK) { #if _TRACE_OUT_PUT PrintMagToTxt("--Open Serial fail---"); #endif return(false); } else { #if _TRACE_OUT_PUT PrintMagToTxt("--Open Serial successfully---"); #endif break; } }while(false); //Set USB/RS232 Overlap time clsPacket.TRANS_API_SetOverlapTime(200, 200); //Clear inventory's infomation buffer clsPacket.TRANS_API_ClearBuffer(); return(true); }
public static TRANS_RESULT TRANS_API_Serial_Open(uint uiComPort, ref DCB r_pDcb) { m_Mutex.WaitOne(); m_Result = dllSerialOpen(uiComPort, ref r_pDcb); m_Mutex.ReleaseMutex(); return m_Result; }