急急急....RS-485串口为什么接收不到数据?懂串口的进来看看啊.. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.IO.Ports;
namespace _2 { public partial class Form1 : Form { SerialPort spReceive = new SerialPort ();
delegate void UpdateTextEventHandler(string text);//声明一个委托 UpdateTextEventHandler updateText;//创建一个委托实例 public Form1() { InitializeComponent(); updateText = new UpdateTextEventHandler(UpdateTextBox);
spReceive.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(spReceive_DataReceived );
private void button1_Click(object sender, EventArgs e) { spReceive.PortName = "COM5"; spReceive.BaudRate = 2400; spReceive.DataBits = 8; spReceive.StopBits = StopBits.One; spReceive.Parity = Parity.Even; //string str = "FE FE FE 68 AA AA AA AA AA AA 68 13 00 DF 16"; //byte[] data = System.Text.Encoding.ASCII.GetBytes(str );