IO Exception Over Serial On Windows
See original GitHub issueI cannot get PyEZ to connect to my juniper switch on Windows using the serial port. For my application I cannot use SSH/telnet and I need it to work over the serial port.
On login I get an error in tty_netconf._receive()
with the usage of select.
According to the official python docs the select operation is not supported on Windows for file objects (https://docs.python.org/3/library/select.html?highlight=select#select.select).
Is there something else than the select than can be used to wait on the IO under Windows ?
Thanks
Here is the command and the output with the error.
Using Windows 10 1809 Python 3.6.8 junos-eznc 2.2.1
To Replicate
import sys
import logging
import time
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
logging.basicConfig(level=logging.DEBUG)
dev = Device(mode='serial', port='COM4', user='root', passwd=None)
dev.open()
Output
INFO:jnpr.junos.tty:TTY: connecting to TTY:COM4 ...
INFO:jnpr.junos.tty:TTY: OK.....starting NETCONF
WRITExml-mode netconf need-trailer
ERROR:jnpr.junos.console:Exception occurred: login:fileno
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 221, in open
raise ex
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 211, in open
self._tty_login()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\console.py", line 316, in _tty_login
self._tty.login()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty.py", line 115, in login
self.nc.open(at_shell=self.at_shell)
File "C:\Users\uesr\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 68, in open
self.hello = self._receive()
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 142, in _receive
raise err
File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 140, in _receive
rd, wt, err = select.select([self._tty._rx], [], [], 0.1)
io.UnsupportedOperation: fileno
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (12 by maintainers)
Top Results From Across the Web
IOException error in opening a virtual serial port with Powershell
Hello,. I have installed a plug-and-play measurement instrument, with a USB terminal, and it appears as a serial COM port.
Read more >SerialPort.Open() --IOException -- "The parameter is incorrect."
I have written the following code to configure the serial port when the MainForm loads. On first run it gives IOException when port...
Read more >serial port: I/O error - Google Groups
What could be the cause of an I/O error on an serial port? I know this is somewhat generic, but... tclkit 8.5.8 on...
Read more >Overview of Serial Port I/O Routines (Windows*)
The serial port I/O (SPORT_ xxx ) routines help you perform basic input and output to serial ports. These routines are available only...
Read more >pySerial API
SerialException – In case the device can not be found or can not be ... For possible values refer to the list for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
console.log
Hi @vnitinv , apolozies for the late reply, there was an power issue with our lab so I have to turn off some device during the weekends.
But good new is that the updated code seem to work, even when the console session was currently in a logged in prompt, which is great. I’ll need to test further functionality with the tableview retrieval and setting new configuration before confirming that everything work as expected. But for now thank you for the update
Attached is the log file (logging output is wrapped in my own custom log format handler ), the only time it produce an error is when another process has already occupied the COM port - which is totally expected and should not be considered a code error.
@vnitinv : I have tried with the context manager but it gives me the the same “io.UnsupportedOperation: fileno” exception. I used --upgrade this time to install the package hoping that it would resolve the issue of not picking up latest code. It did uninstall and reinstall the package.
I tried with context manager this time and got a different exception (the lib looks the same though):