1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| // init bool open avec letat du port
BOOL bOpen = m_pCom->PortOpen::get();
System::Runtime::InteropServices::COMException commErreur;
if (bOpen == false) // si port pas ouvert
{
try
{
m_pCom->PortOpen::set(1); // ouvre com
throw commErreur;
Sleep(TIMERDELAI); // attente init
// init buffers
m_pCom->InputLen::set(0);
m_pCom->InBufferCount::set(0);
m_pCom->OutBufferCount::set(0);
SetIntervalleTimer(TIMERDELAI); // init intervalle timer
timer_scrute->Start(); // lance timer
bOpen = true; // force open a true
}
catch (System::Runtime::InteropServices::COMException erreur)
{
System::Windows::Forms::DialogResult result = MessageBox::Show("erreur","Erreur",System::Windows::Forms::MessageBoxButtons::OK,System::Windows::Forms::MessageBoxIcon::Error);
}
}
return bOpen; // retourne open : 1 ouverture reussi; 0:echec
} |
Partager