Posiłkując się tutorialem piszę program który ma na celu odbiór danych wysyłanych przez Arduino.
W linii
if(!this->_serialPort->IsOpen){
dochodzi do błędu System.NullReferenceException, i wyświetlenia komunikatu " Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu."
Siedzę, patrzę i już nie wiem. Poratuje ktoś ?
this->textBox1->Text=String::Empty;
if(this->comboBox1->Text==String::Empty||this->comboBox2->Text==String::Empty)
this->textBox1->Text="Proszę wybrać ustawienia portu COM";
else{
try{
if(!this->_serialPort->IsOpen){
this->_serialPort->PortName=this->comboBox1->Text;
this->_serialPort->BaudRate=Int32::Parse(this->comboBox2->Text);
this->_serialPort->Open();
this->StanPortu->Value=100;
this->textBox1->Text=this->_serialPort->ReadLine();
}
else
this->textBox1->Text="Port nie otwarty";
}
catch(UnauthorizedAccessException^){
this->textBox1->Text="UnauthorizedAccess";
}
}