我正在使用激光切割器/雕刻机,这是Lasersaur开源激光切割机/雕刻机项目的一部分。我完成了硬件构建,没有意识到涉及到一些软件编程,在这种情况下是Python。我对Python一无所知,我有什么编码体验是在C#中从头开始构建一个定制的CMS。在Python 2.7.2中设置端口以与Arduino Uno配合使用
这是我的设置
电脑:东芝Satellite A-105
操作系统:Windows XP,SP3
代码:Python 2.7版
开发板:Arduino的乌诺
Arduino客户与Uno主板通话良好,所有的测试和上传工作。使用Arduino网站的入门指南,我可以设置一个COM端口供COM7使用,在这种情况下。问题是,当我运行的Python GUI和编译由Lasersaur提供我得到这个错误代码:
Traceback (most recent call last):
File "C:\LASERSAUR\lasersaur_Grbl\stefanix-LasaurGrbl-dac1a86\flash.py", line 128, in <module>
devices = os.listdir("/dev")
WindowsError: [Error 3] The system cannot find the path specified: '/dev/*.*'
在Lasersaur的人说,我需要设置的COM端口中的代码。我只是不知道自己做了些什么,或者提出了正确的问题。大量的阅读后然而,在我盯着屏幕,我相当肯定,我需要在这里设置端口:
## define serial port
##
if len(sys.argv) == 2:
# (1) get the serial device from the argument list
SERIAL_PORT = sys.argv[1]
print "Using serial device '"+ SERIAL_PORT +"' from command line."
else:
if os.path.isfile(CONFIG_FILE):
# (2) get the serial device from the config file
fp = open(CONFIG_FILE)
line = fp.readline().strip()
if len(line) > 3:
SERIAL_PORT = line
print "Using serial device '"+ SERIAL_PORT +"' from '" + CONFIG_FILE + "'."
if not SERIAL_PORT:
# (3) try best guess the serial device if on linux or osx
devices = os.listdir("/dev")
for device in devices:
if device[:len(GUESS_PPREFIX)] == GUESS_PPREFIX:
SERIAL_PORT = "/dev/" + device
print "Using serial device '"+ SERIAL_PORT +"' by best guess."
break
我相当肯定,这将是一个额头拍打的答案,当我看到它。但任何帮助,将不胜感激。请让我知道你是否需要更多的细节。
V/R
K.澳元
替换它 “'WindowsError:[错误3]系统无法找到指定的路径: '的/ dev /*.*''”。 '/ dev'是一个Unix路径。你在Windows上运行。 – Johnsyweb 2012-01-29 02:06:44
你用什么命令行参数来启动这个脚本?它看起来像传递给脚本的任何参数(如果有的话)都没有被读取,python跳转到较低的代码块。 – 2012-01-29 02:43:51