tbickford
tbickford

Reputation: 41

Python: PyVISA vs PySerial?

I work with various instruments such as scopes, rs232, rs422, serial to usb converters, and so on. I am having a hard time finding the differences between PyVISA and Pyserial. Is one strictly better than the other (unlikely I'm sure)? Does each have it's own strengths and weaknesses? Is a mixed approach most common?

I have worked with both PySerial and PyVISA and they generally seem to do the same thing. The internet has suggested: PyVISA for instrumentation automation control with scopes and GPIB devices, and PySerial for RS232 & other serial protocols.

So, in short, when should I use PyVISA versus PySerial?

Upvotes: 0

Views: 1000

Answers (1)

Al Roborol
Al Roborol

Reputation: 11

Put aside the opinions, there are some cases that forces you to choose one even only for RS232 access. As far as I know:

  • If you want to read and write data using numpy, use pyVISA
  • If you want to access RS232 as read/write a normal file, use pySerial. e.g. using readline()
  • If you want import name be that same as pip install name, use pyVISA (just a joke. I hope someday I can import pyserial instead of serial for using it)

Of course there are many other key differences beyond my experience.

Upvotes: 0

Related Questions