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

Struggles with USB-Serial Adapter / toptica_ibeam.py #969

Open
waveman68 opened this issue Sep 22, 2023 · 6 comments
Open

Struggles with USB-Serial Adapter / toptica_ibeam.py #969

waveman68 opened this issue Sep 22, 2023 · 6 comments
Labels
bug diagnosed Solution proposed, needs implementation instrument

Comments

@waveman68
Copy link
Contributor

waveman68 commented Sep 22, 2023

We have considerable issues using the toptica_ibeam.py instrument with the USB-serial adapter that Toptica provided. We managed to get it working more or less but faced a number of issues when upgrading to 0.12 (we already submitted a fix that is already in 0.13).

The core issue is one of timing or buffer management. We regularly get responses from previous commands. This error leads us to believe that it may be a buffer issue:

laser = IBeamSmart(adapter="ASRL/dev/ttyUSB0::INSTR", baud_rate=115200)
temperature_diode gave unexpected response OFF  # this should be a float

# setting the power causes this:
Setting self.laser.power caused error 'SerialInstrument' object has no attribute 'flush_read_buffer'

Adjusting the query_delay per documentation (BTW: this causes a deprecation warning) does not help – 200 ms should be more than enough. I guess we are supposed to override wait_for?

.../pymeasure/adapters/visa.py:90: FutureWarning: Parameter `query_delay` is deprecated. Implement in Instrument's `wait_for` instead.

At some point there was an adapter.py for toptica_ibeam.py but this was removed. Is there some way of restoring the 'flush_read_buffer'? I would be happy to do a PR if someone would point me in the right direction.

Note: I have looked at other issues like #965, # #567 and even the original PR #352 toptica_ibeam.py and haven't really been able to get traction.

@BenediktBurger
Copy link
Member

I found something:
self.adapter.connection.flush_read_buffer()

self.adapter.connection.flush_read_buffer()

These lines cannot work, as the pyvisa.SerialInstrument does not have a flush_read_buffer method.
Instead, the lines should be self.adapter.flush_read_buffer. Could you try that, please?

Some informational comments:

Adjusting the query_delay per documentation (BTW: this causes a deprecation warning) does not help – 200 ms should be more than enough. I guess we are supposed to override wait_for?

Yes, you're supposed to override wait_for.

At some point there was an adapter.py for toptica_ibeam.py but this was removed.

Exactly, there was an adapter for the ibeam, but we moved the logic from that adapter into the ibeam_smart itself in order to be able to use doctests and to harmonize adapter usage in the codebase.

@BenediktBurger
Copy link
Member

BenediktBurger commented Sep 23, 2023

Those two lines are definitively wrong and have to be changed as indicated (would you mind doing that as a PR?).
I wonder, whether that is the issue.

Maybe protocol tests can help to test that functionality and to ensure, that it continues to work as exspecetd.

@BenediktBurger
Copy link
Member

I created a PR #1065 which fixes the code bug I found above.
Would you mind testing, whether this fixes your problem @waveman68 ?

@waveman68
Copy link
Contributor Author

waveman68 commented Apr 30, 2024

Yes, I would but I'm currently in home office after an operation.

BTW, the pyserial implementation of a terminal with pipes (miniterm) never caused problems.

@BenediktBurger
Copy link
Member

I wish you a good recovery.

@BenediktBurger
Copy link
Member

By the way, PR #1065 has been merged, therefore the fix is in the master and might be shortly on Pypi, depending on #1104.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug diagnosed Solution proposed, needs implementation instrument
Projects
None yet
Development

No branches or pull requests

3 participants