bicarlsen / easy-scpi

A library to control SCPI instruments
GNU General Public License v3.0
53 stars 20 forks source link

Problem with sending commands - no termination sign #9

Closed Cosik closed 1 year ago

Cosik commented 1 year ago

Hi, I have a problem with sending commands over TCPIP using this lib.

Simple code: inst = scpi.Instrument(port_match=False) inst.rid='TCPIP0::192.168.8.211::30000::SOCKET' inst.connect() print(inst.id())

TCPIP0::192.168.8.211::30000::SOCKET Traceback (most recent call last): return self.query( '*IDN?' ) raise errors.VisaIOError(rv) pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

What I observe is that even to use pyvisa manager I have to set termination sign. I tried in such way:

inst.__inst.read_termination = '\n'
inst.__inst.write_termination = '\n'

But it is not working this should be set in such way: self.inst = self.rm.open_resource( self.rid, read_termination = '\n', write_termination = '\n')

Do you have any workaround or hint how to fix that without changing a code??

`pip list Package Version


easy-scpi 0.1.4 modbus-tk 1.1.2 pip 21.2.3 pymodbus 3.0.2 pyserial 3.5 PyVISA 1.13.0 PyVISA-py 0.6.0 setuptools 57.4.0 typing_extensions 4.4.0`

bicarlsen commented 1 year ago

If I understand correctly you are trying to set the read and write termination characters. This can be done by setting it directly on the SCPI_Instrument during initialization as passed in via the **resource_params.

import easy_scpi as scpi

inst = scpi.Instrument(<port>, read_termination='\n', write_termination='\n')

You can see an example of this in the full example on the README.

Cosik commented 1 year ago

Hi,

Sorry, I've missed somehow this information. Btw very good job with this library :)

bicarlsen commented 1 year ago

Happy to help, and glad you are finding the package useful :) Please feel free to raise another issue if you run into any trouble.