question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'GPIBInstrument' object has no attribute 'flush'

See original GitHub issue

Problem

The flush() method cannot be called on a GPIBInstrument object

I can do this from Labview, and the official NI VISA documentation says that viFlush() is valid for the following resource classes: GPIB INSTR, GPIB INTFC, Serial INSTR, TCPIP INSTR, TCPIP SOCKET, VXI INSTR, VXI SERVANT

From looking at the pyvisa code, it appears as though the only resource class that has flush() implemented is asynchronous serial.

Steps to reproduce

import visa
rm = visa.ResourceManager()
session = rm.open_resource('GPIB0::5::INSTR')
session.flush()

returns this error:

Traceback (most recent call last):
session.flush(0b00100000)
AttributeError: 'GPIBInstrument' object has no attribute 'flush'

Proposed fix

Implement flush() by calling viFlush() within the GPIBInstrument class, and any other objects in the list above where it’s safe to be called.

If you’d like that in the form of a pull request I can handle that, but wanted to ensure that this is indeed a bug and not a mis-interpretation on my end.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MatthieuDartiailhcommented, Feb 5, 2019

VXI is not widely used with PyVISA (at least I never heard of anybody using it), so it is fine to skip the implementation.

0reactions
KM4YRIcommented, Jul 24, 2020

Nice, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

'GPIBInstrument' object has no attribute 'ask' - Stack Overflow
I am now using python to get data from lock in amplifer with GPIB and met a ... Error report; AttributeError: 'GPIBInstrument' object...
Read more >
AttributeError: 'NoneType' object has no attribute 'flush'
someon knows why i have that error, Warning (from warnings module): File ... AttributeError: 'NoneType' object has no attribute 'flush'.
Read more >
PyVISA Documentation - Read the Docs
In this case, I have a GPIB instrument with instrument number 14, so I create the instance. (i.e. variable) called my_instrument accordingly ...
Read more >
Stream Object has no attribute flush - Google Groups
I came up with a problem when i run my program in another Linux environment, it seems that i haven't installed something. I...
Read more >
Instruments — PyVISA 1.5 documentation - Read the Docs
For this, have a look at the specialised classes like GpibInstrument (section Common ... The class Instrument defines the following methods and attributes:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found