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 33 34 35
|
try
{
serialPort1->DtrEnable = true;
serialPort1->RtsEnable = true;
serialPort1->DataBits = 7;
serialPort1->BaudRate = 9600;
serialPort1->Handshake = System::IO::Ports::Handshake::RequestToSend;
serialPort1->Parity = System::IO::Ports::Parity::Even;
serialPort1->ReadBufferSize = 1024;
serialPort1->WriteBufferSize = 1024;
serialPort1->Open();
MessageBox::Show("Port COM disponible", "Port COM disponible", MessageBoxButtons::OK, MessageBoxIcon::Information);
MessageBox::Show("La CN doit être en mode dechargement", "dechargement", MessageBoxButtons::OK, MessageBoxIcon::Warning);
}
catch (Exception^)
{
MessageBox::Show("Impossible d'ouvrir le port COM.\n Il est déjà en cours d'utilisation, a été supprimé, ou n'est pas disponible", " Port COM indisponible", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
array<wchar_t> ^sendBuffer = gcnew array<wchar_t>(1024);
serialPort1->Read(sendBuffer, 0,1024);
StreamWriter^ lec = gcnew StreamWriter(chemin);
lec->WriteLine(sendBuffer);
lec->Flush();
lec->Close();
serialPort1->Close();
logSW->WriteLine(""+DateTime::Now+" RECEPTION DU PROGRAMME "+prog);
textbox_reception->Clear();
} |
Partager