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
|
// Initialisation
serialPort1.BaudRate = 57600;
serialPort1.PortName = cmbBxPortCOM.Text;
serialPort1.Parity = System.IO.Ports.Parity.None;
serialPort1.DataBits = 8;
serialPort1.StopBits = System.IO.Ports.StopBits.One;
serialPort1.Encoding = Encoding.UTF8;
serialPort1.DiscardNull = false;
serialPort1.ReceivedBytesThreshold = 1;
serialPort1.ParityReplace = 0;
serialPort1.Handshake = 0;
serialPort1.DtrEnable = false;
serialPort1.RtsEnable = false;
serialPort1.Open();
txtBxLogIRDA.Text += "OPen" + serialPort1.PortName + ":" + serialPort1.IsOpen.ToString() + "\r\n";
//ecriture
char[] buf = new char[4];
buf[0] = (char)86;
buf[1] = (char)63;
buf[2] = (char)13;
buf[3] = (char)10; //buf = "V?"
txtBxLogIRDA.Text += "TIMEOUT WRITE:" + serialPort1.WriteTimeout.ToString() + "\r\n";
try
{
serialPort1.Write(buf,0,4);
}
catch (Exception excpt)
{
txtBxLogIRDA.Text += "EXCEPTION:" + excpt.Message.ToString() + "\r\n";
} |
Partager