帮助.....串行端口编程 [英] help.....serial port programming

查看:62
本文介绍了帮助.....串行端口编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在python中与我的串行端口通信.我安装了pyserial和用于Linux的uspp.尽管如此,当我运行以下代码时:

I want to communicate with my serial port in python. I installed pyserial, and uspp for linux. Still, when I run the following code:

import serial

ser = serial.Serial('/dev/pts/1', 19200, timeout=1)

print ser.portstr #check which port was really used

ser.write("hello") #write a string

ser.close() #

它给出了以下错误:

Traceback (most recent call last): 
File "poi.py", line 5, in ser.open() 
File "/usr/local/lib/python2.6/dist-packages/pyserial-2.5-py2.6.egg/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 /dev/tyUSB1: [Errno 2] No such file or directory: '/dev/tyUSB1'

我该怎么办?

推荐答案

/dev/tyUSB1 看起来像是一个错字.设备节点通常称为/dev/ttyXXX

/dev/tyUSB1 looks like a typo. Device nodes are normally called /dev/ttyXXX

这篇关于帮助.....串行端口编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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