private void Form1_Load(object sender, EventArgs e) { string data = "02(hex)B03(hex)"; try { serialPort1 = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One); serialPort1.Handshake = Handshake.None; serialPort1.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); serialPort1.ReadTimeout = 500; serialPort1.WriteTimeout = 500; serialPort1.Open(); serialPort1.Write("02(hex)B03(hex)"); } catch (Exception ex) { MessageBox.Show("MENSAGE:",ex.Message); } } void sp_DataReceived(object sender, SerialDataReceivedEventArgs e) { MessageBox.Show("sp_DataReceived"); if (this.Enabled == true) { MessageBox.Show("Enabled"); Thread.Sleep(500); string data = serialPort1.ReadExisting(); this.BeginInvoke(new DelegadoAcceso(si_DataReceived), new object[] { data }); } }
serialPort1.Write("02(hex)B03(hex)");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)