echo 串口发送命令,从linux命令行写入串口

From windows I can communicate with a serial port device using following commands:

mode com1: baud=9600 data=8 parity=n stop=1

copy con com1

alt+18alt+2ctrl+z

Device starts the requested operation.

When I try to accomplish the same operation from a stand alone debian box or from a debian virtualbox instance of the same windows machine, I had no luck so far.

Here's equivalent linux commands(at least I think so)

stty -F /dev/ttyS0 speed 9600 cs8 -cstopb -parenb

echo '\x12\x02' > /dev/ttyS0

Nothing happens.

Can somebody please direct me to the right direction?

解决方案echo '\x12\x02'

will not be interpreted, and will literally write the string \x12\x02 (and append a newline) to the specified serial port. Instead use

echo -n ^R^B

which you can construct on the command line by typing CtrlVCtrlR and CtrlVCtrlB. Or it is easier to use an editor to type into a script file.

The stty command should work, unless another program is interfering. A common culprit is gpsd which looks for GPS devices being plugged in.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值