在pc104中使用串口发送/接收 [英] send/receive with serial port in pc104

查看:53
本文介绍了在pc104中使用串口发送/接收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在pc104中使用串口发送/接收。我使用vs2005与frw compact 2.0并在我用vs2005生成的pc104上获胜。



i用vs2005编写这个示例代码,用于在pc104中发送/接收



我说我的程序在哪里错了?



有我的示例代码:

http://cboard.cprogramming.com/csharp-programming/159074 -send-receive-serial-port-pc104.html [ ^ ]

推荐答案

ok,

你是对的。
在PC104上
我不能通过我在vs2005 whit frw 2.0 compact中生成的应用程序从pc104发送/接收数据。

这些代码在我的应用程序中:

com端口的此按钮设置值:

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:
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;

}





此代码打开com端口:



this code open com port :

serialPort1.Open();





此代码从com端口接收数据:



this code receive data from com port :

private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
    textBox1.Text=serialPort1.ReadLine();

}





此代码从comport发送数据:



this code send data from comport :

private void button3_Click(object sender, EventArgs e)
{
    serialPort1.Write(textBox2.Text);
}


这篇关于在pc104中使用串口发送/接收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆