pyvisa / pyvisa

A Python package with bindings to the "Virtual Instrument Software Architecture" VISA library, in order to control measurement devices and test equipment via GPIB, RS232, or USB.
https://pyvisa.readthedocs.io
MIT License
800 stars 249 forks source link

Question: How to Deal with Instrument that Sends Read Termination Character Twice #658

Open lovetheguitar opened 2 years ago

lovetheguitar commented 2 years ago

Hello lovely people,

I'm working with some unruly SCPI instruments here. They always send \n\n at the end of every message. So if I specify res.read_termination = "\n" - I always get two messages - first the correct message and second an empty message, only consisting of the second newline character.

How can I deal with that? On another PC with a different GPIB driver I always got a single message with one or two newline characters, depending on the value of the read_termination attribute.

Online and in the device menu I did not find any option to change this behavior. 😢

Thanks for any help.

PS: On the PC where I always got the reply in a single message, I managed to "help myself" by commenting out this check https://github.com/pyvisa/pyvisa/blob/53a1d410f727e8d16212ceae3229e6219443f9aa/pyvisa/resources/messagebased.py#L106-L107.

Instrument details

MatthieuDartiailh commented 2 years ago

Sorry for missing your post. I am not sure you can do better than reading twice. Having twice the same character makes indeed for an ambiguous situation.