简体   繁体   English

创建串口设备文件

[英]Create serial port device file

I need to develop a test program, which sends and recieves data from terminal to the serial port. 我需要开发一个测试程序,该程序可以从终端向串行端口发送和接收数据。
In order to do that I want to create virtual device file and work with it. 为此,我想创建虚拟设备文件并使用它。 I did that by using command: 我通过使用命令来做到这一点:

mknod -m 666 ttyS32 c 4, 500 mknod -m 666 ttyS32 c 4,500

The device file was successfully created, however I can't write data to it. 设备文件已成功创建,但是我无法向其中写入数据。 Both programmatical and terminal ways give the following error: 编程方式和终端方式均产生以下错误:

No such device or address 没有这样的设备或地址

In CI used standard file I/O functions, and in terminal I used the 'echo' command. 在CI中,使用标准文件I / O功能,而在终端中,使用'echo'命令。 Do you have any ideas how to write data to serial port device file? 您有任何想法如何将数据写入串行端口设备文件吗?

That's right. 那就对了。 You can write to the serial device using echo . 您可以使用echo写入串行设备。 Are you sure that the device (not the device file) exists and is properly handled by the driver? 您确定设备(不是设备文件)存在并且已被驱动程序正确处理吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM