Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isOpen() and is_open always return True #485

Open
smurpau opened this issue Feb 17, 2020 · 1 comment
Open

isOpen() and is_open always return True #485

smurpau opened this issue Feb 17, 2020 · 1 comment
Labels

Comments

@smurpau
Copy link

smurpau commented Feb 17, 2020

Same issue here. Fixed delay is the only workaround.

My setup:

  • Windows 10
  • pyserial 3.4 from pypi
  • python 3.6.5
  • serial device is a FTDI FT232RL

Tried software flow control, hardware flow control, setting read/write-timeout. In addition I put isOpen() right after serial open and it always returns True, despite silently failing to write (with timeout of 1 second). The read after the write runs into the timeout and does not return the expected repsonse but an empty string.

As a workaround I need to wait for 2 seconds (1 is not enough) and then I can query with the device with read delays of about 30 ms no problem.

If you need to have something tested on my setup, just let me know!

Originally posted by @axel-kah in #329 (comment)

I have the same issue as the above user.

  • Windows 10
  • pyserial 3.4 from anaconda
  • python 3.8.1 x64
  • any real or emulated serial device

A call to open() always results in is_open returning True, even if the opening actually failed by timing out. There is thus no way to detect a nonexistent or dropped serial connection, which is quite surprising behaviour to say the least.

The issue appears to arise here: is_open is not set to False on an exception, nor is it set to false in _close(). It is in close(), but that is not called.

@zsquareplusc
Copy link
Member

is_open = True is set in the else clause of the try/except, so it will be only true if there is no error. Also at the beginning of the function there is a check that is_openis false. So I do not see how is_open should be in the wrong state.

The example quoted in the issue sounds like a device that is not immediately ready after opening, that's not the fault of the serial port, the OS or this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants