omid omidan

omid omidan

  • NA
  • 3
  • 1.4k

Send/Receive with Serial Port in pc104

Sep 12 2013 4:09 AM
on pc104 i can`t send/receive data from/to pc104 by my generated application in vs2005 whit frw 2.0 compact.
these code are in my application :
this button set value for com port:
private void set_Click(object sender, EventArgs e) { serialPort1=new SerialPort(); serialPort1.PortName = comboBox1.Text; serialPort1.DtrEnable = checkBox4.Checked; serialPort1.RtsEnable = checkBox5.Checked; serialPort1.BaudRate=1200; serialPort1.StopBits= StopBits.One; serialPort1.DataBits=8; serialPort1.Parity= Parity.None; serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived); button1.Enabled = false; }  
this code open com port :
serialPort1.Open();  
this code receive data from com port :
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { textBox1.Text=serialPort1.ReadLine();   }  
this code send data from comport :
private void button3_Click(object sender, EventArgs e) { serialPort1.Write(textBox2.Text); }

Answers (2)