Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi,

i want do send/receive with serial port in pc104 . i use vs2005 with frw compact 2.0 and win ce on pc104 that i generated with vs2005.

i write this sample code with vs2005 for send/receive in pc104

say me where in my program is wrong?

There is my sample code :
http://cboard.cprogramming.com/csharp-programming/159074-send-receive-serial-port-pc104.html[^]
Posted
Comments
Sergey Alexandrovich Kryukov 12-Sep-13 1:14am    
This is not a valid question. The code could be wrong or correct only if you explain what you wanted to achieve, what do you observer instead and why do you think it's wrong. Besides, when it comes to serial port communications, who knows what's on the other end of the RS-232 cable? How do you know if the other side behave correctly? And you need to know its specs.
—SA

1 solution

ok,
you`re right .
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:
C#
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 :
C#
serialPort1.Open();


this code receive data from com port :
C#
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
    textBox1.Text=serialPort1.ReadLine();

}


this code send data from comport :
C#
private void button3_Click(object sender, EventArgs e)
{
    serialPort1.Write(textBox2.Text);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900