发送数据串口 [英] Send data serial port
问题描述
您好,我有一个包含数据的.dat文件,我想通过串口rs232通讯发送此数据。我使用紧凑型框架visula studio 2008,C#。
i不知道如何发送文件内的数据.dat
谢谢: )
我尝试了什么:
你好,我有一个包含数据的.dat文件,我想通过串口rs232通信发送这个数据。我使用紧凑型框架visula studio 2008,C#。
i不知道如何发送文件内的daya .dat
谢谢: )
Hi there, i have a .dat file which contain data, and i want to send this data through serial port rs232 communication. i use compact framework visula studio 2008,C#.
i have no idea how to send the data that is inside file .dat
thanks:)
What I have tried:
Hi there, i have a .dat file which contain data, and i want to send this data through serial port rs232 communication. i use compact framework visula studio 2008,C#.
i have no idea how to send the daya that is inside file .dat
thanks:)
推荐答案
创建一个SerialPort实例: SerialPort类(System.IO.Ports) [ ^ ],正确设置接口参数,使它们与otehr端的设备匹配(链接)包括一个示例)并打开它。
然后读取文件并发送它:
Create a SerialPort instance: SerialPort Class (System.IO.Ports)[^], set the interface parameters correctly so they match the equipment at the otehr end (the link includes an example) and open it.
Then read the file and send it:
byte[] data = File.ReadAllBytes(pathToDATFile);
mySerialPort.Write(data, 0, data.Length);
这篇关于发送数据串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!