Following an example on resetting a serial port in Linux I wanted to translate the following snippet
fd = open(filename, O_WRONLY);
ioctl(fd, USBDEVFS_RESET, 0);
close(fd);
into valid python code. Here is what I have tried so far
file_handler = open(self._port, 'w')
fcntl.ioctl(file_handler, termios.USBDEVFS_RESET)
file_handler.close()
which ends with an error 'module' object has no attribute 'USBDEVFS_RESET'
. The termios documentation is not very helpful in this point, as it does not list the possible properties of termios
. See also the fcntl documentation for an example of such a termios
property.
How to I 'convert' the C code to python2.7 code correctly?
USBDEVFS_RESET
has the value_IO('U', 20)
. I do not need to try your suggestion to see that this won't work. So the original question remains unanswered. Maybe you know what_IO('U', 20)
is? Replacingtermios.USBDEVFS_RESET
simply by20
gives the error:IOError: [Errno 22] Invalid argument
. – Abomb