如何在Cygwin中使用COM和USB端口? [英] How can I use COM and USB ports within Cygwin?

查看:1420
本文介绍了如何在Cygwin中使用COM和USB端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Python脚本从我的Arduino板发送/接收数据。我想使用Python和它的pySerial模块,这似乎符合我的需要。所以我在cygwin(windows XP后面)中安装了python和pySerial。

I want to send/receive data from my Arduino board with a Python script. I would like to do it using Python and its pySerial module which seems to fit my needs. So I installed Python and pySerial within cygwin (windows XP behind).

Python脚本很简单:

The Python script is rather straightforward:

$ cat example.py

#print "testing my COM26 port using python"

import serial
ser = serial.Serial()
ser.baudrate = 9600
ser.port = 26
ser
ser.open()
ser.isOpen()

但是在运行时我收到以下错误。

However at runtime I get the following error.

$ python example.py
Traceback (most recent call last):
  File "example.py", line 9, in <module>
    ser.open()
  File "/usr/lib/python2.5/site-packages/serial/serialposix.py", line 276, in open
    raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port 26: [Errno 2] No such file or directory: '/dev/com27'




无法打开端口26:[Errno 2]没有此类文件或目录:'/ dev / com27'

Could not open port 26: [Errno 2] No such file or directory: '/dev/com27'

我如何知道我的Arduino连接到COM27端口?

How do I know my Arduino is connected to port COM27?

好吧,很简单。 Arduino IDE说,所以,我可以使用该端口从IDE的串行端口监视器工具发送和接收数据。

Well, it's simple. The Arduino IDE says so, I can send and receive data from the Serial Port Monitor tool for the IDE using that port. Besides, I managed to get the hyperterminal working using that port too.

但是,Cygwin似乎并不知道这样的USB和COM端口:

However, it seems Cygwin is not aware of such USB and COM ports:

$ ls -lah /dev
total 4,0K
.
..
fd -> /proc/self/fd
mqueue
shm
stderr -> /proc/self/fd/2
stdin -> /proc/self/fd/0
stdout -> /proc/self/fd/1

应该提到的是,没有经典的串行COM端口,只是USB端口。 (所以我想这是很平常的例如 / dev / com1 不存在。)

It should be mentioned that I am running this on a Dell laptop that has no classic serial COM port, just USB ports. (So I guess it's plain normal for instance that /dev/com1 does not exist.)

但是我的问题是:我如何配置Cygwin以使其变得对COM27端口感觉到。

I don't know if I'm asking correctly, but my question is: how can I configure Cygwin so that it becomes aware of this COM27 port?

推荐答案

如果Hyperterminal可以访问它,则它被安装为虚拟COM端口。 Cygwin将允许您以 / dev / ttyS26 (由Windows调用COM27)访问它。您可能仍有输入阻塞的问题,直到收到CR - 我这样做。 (尝试解决 ,是我如何找到 。)

If Hyperterminal can access it, then it's installed as a "virtual COM port". Cygwin will let you access it as /dev/ttyS26 (called COM27 by Windows). You may still have an issue with the input blocking until a CR is received--I do. (Trying to solve that, is how I found this.)

这篇关于如何在Cygwin中使用COM和USB端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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