【发布时间】:2013-01-31 12:59:25
【问题描述】:
按照Linux中resetting a serial port的示例,我想翻译以下sn-p
fd = open(filename, O_WRONLY);
ioctl(fd, USBDEVFS_RESET, 0);
close(fd);
转换成有效的 python 代码。这是我迄今为止尝试过的
file_handler = open(self._port, 'w')
fcntl.ioctl(file_handler, termios.USBDEVFS_RESET)
file_handler.close()
以错误 'module' object has no attribute 'USBDEVFS_RESET' 结尾。 termios documentation 在这一点上不是很有帮助,因为它没有列出 termios 的可能属性。有关此类 termios 属性的示例,另请参见 fcntl documentation。
如何正确地将 C 代码“转换”为 python2.7 代码?
【问题讨论】:
标签: python python-2.7 ioctl fcntl