0
저는 LM4F232H5QD 보드에서 작업 중이며 com 포트 데이터를 읽으려고합니다. Tera 용어 나 다른 직렬 터미널을 사용할 때마다 com 포트에서 데이터를 얻습니다.C++을 사용하여 COM 포트에서 쓰기 데이터를 읽으려고 시도했습니다.
하지만이 코드를 사용하면 code 타임 아웃 예외 오류가 발생합니다.
// _serialPort
//
this->_serialPort->PortName = L"COM3";
this->_serialPort->ReadTimeout = 5000;
this->_serialPort->WriteTimeout = 5000;
.
.
.
.
// Read button --------------------------------------
//this will start the asyn for backgroundwork
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
// check if port is ready for reading
if(this->_serialPort->IsOpen){
// Reset the text in the result label.
this->textBox2->Text = String::Empty;
// this will read manually
try{
this->textBox2->Text=this->_serialPort->ReadLine();
// printf("trying to read data");
}
catch(TimeoutException^){
this->textBox2->Text="Timeout Exception";
}
// Disable the init button
// the asynchronous operation is done.
this->button2->Enabled = false;
this->ovalShape1->FillColor= Color::Green;
}
else
// give error warning
this->textBox2->Text="Port Not Opened";
}
그러나 짧은 Rx 및 Tx 핀은 잘 작동합니다.
누구든지이 문제를 어떻게 해결할 수 있습니까?
_ "하지만 짧은 Rx 및 Tx 핀은 잘 작동합니다."_ 실제로이 작업을 수행하는 방법을 보여줄 수 있습니까? –