|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: May 2006
Città: Milano&Palermo
Messaggi: 10273
|
[C#] problemi con la classe SerialPort
Salve a tutti
Usando realterm va tutto bene, ma con C# sembra che non funzioni niente! riceve entrambi i byte sbagliati! ecco il codice: Codice:
private void Update(byte led)
{
byte[] bah = new byte[3];
bah[0] = led;
try
{
comPort.Write(bah, 0, 1);
}
catch (NullReferenceException)
{
statusLabel.Text = "Devi prima connetterti";
return;
}
catch (InvalidOperationException)
{
statusLabel.Text = "Devi prima riconnetterti";
return;
}
try
{
comPort.Read(bah, 1, 2);
}
catch (TimeoutException)
{
statusLabel.Text = "Errore di timeout! Nessuna risposta dal PIC!";
}
if ((byte)(bah[0] ^ lastStatus) == bah[1])
statusLabel.Text = "Comando inviato con successo!";
else
statusLabel.Text = "Errore!";
adcProgressBar.Value = bah[2];
lastStatus = bah[1];
statusLabel.Text = bah[0].ToString() + ", " + bah[1].ToString() + ", " +
bah[2].ToString();
updateCheckBoxes(bah[1]);
}
__________________
PC9Ryzen 9 3900X64GB Vengeance LPXGigabyte RTX3080TiCorsair MP600Aorus Elite X570 - PC10SQ216GB LPDDR4256 GB SSDSurface Pro X - PC11Core i9-9980HK64GB DDR4512GB SSDMacBook Pro 2019 - xboxlivekipters - originkipter - steamkippoz - psnkipters |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:50.



















