从UNIX命令行发送字节到串行端口? [英] Sending bytes to serial port from UNIX command line?

查看:75
本文介绍了从UNIX命令行发送字节到串行端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用命令行将字节流发送到串行端口。这可能吗?我的串行端口在Mac上的 /dev/cu.usbserial-A700dYoR 中。例如,如果我想向该串行端口发送整数50或字符串 data,我该怎么做?



我对UNIX的了解非常有限。

解决方案

 #!/ bin / bash 

#端口设置
stty -F /dev/cu.usbserial-A700dYoR原始速度9600

echo'Hello'> /dev/cu.usbserial-A700dYoR

或类似的东西,如果我没记错的话...几年。您可能必须要 sudo 才能起作用...



这是在发送文本...不是二进制...发送数字50作为文本

  echo'50'> /dev/cu.usbserial-A700dYoR 

将其作为二进制整数发送会更加困难。 / p>

i would like to send a stream of bytes to a serial port using the command line. is this possible? my serial port is at /dev/cu.usbserial-A700dYoR on my Mac. for example, if i wanted to send the integer 50 or the string "data" to that serial port, how can i do that?

my knowledge of UNIX is very limited.

解决方案

#!/bin/bash

# Port setting
stty -F /dev/cu.usbserial-A700dYoR raw speed 9600

echo 'Hello' > /dev/cu.usbserial-A700dYoR

or something like that if I remember correctly... Been a few years. You will probably have to be sudo for it to work...

This is sending text... not binary.. to send the number 50 as text

echo '50' > /dev/cu.usbserial-A700dYoR

to send it as a binary integer would be more difficult.

这篇关于从UNIX命令行发送字节到串行端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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