pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
288 stars 124 forks source link

Large messages not sent correct via TCP/IP #340

Closed wintermuteger closed 1 year ago

wintermuteger commented 2 years ago

Hi pyvisa team,

I am trying to upload a larger file via Visa to an instrument. I want to use a tcp/ip based connection. Unfortunately it failed, whenever the size of the message exceeded 1024 bytes.

After quite some debugging the root cause seems to be in the referenced line of code:

https://github.com/pyvisa/pyvisa-py/blob/3f63d8ac3140e2d6a8f4cf0f68e4a82ab469963b/pyvisa_py/tcpip.py#L541

chunk_size is set to 1024 and is used to feed the while loop. Selection of data is using self.max_recv_size, which defaults to 4096.

https://github.com/pyvisa/pyvisa-py/blob/3f63d8ac3140e2d6a8f4cf0f68e4a82ab469963b/pyvisa_py/tcpip.py#L552

Therefore in my example of about 1.5kb the full block is sent via TCP/IP, but the EOI indicator is not set, as chunk_size was smaller than 1.5kb and the flag selection assumed that a second chunk would follow.

My proposal would be to replace self.max_recv_size in line 552 by chunk_size so the inherent logic of the code is maintained. Afterwards the chunk_size could be kept at the hard coded 1024 or be linked to self.max_recv_size unifying it with the receive direction block size.

MatthieuDartiailh commented 2 years ago

Could you make a PR with your proposed changes ?

I will have to dive into the VXI-11 spec to figure out if there is a link between the send and receive sides.

MatthieuDartiailh commented 2 years ago

Actually the vxi-11 specification (http://www.vxibus.org/specifications.html) explicitly says that maxRecvSize the size of the largest data parameter the network instrument server can accept in a device_write RPC. This value SHALL be at least 1024. so please just get rid of chunk_size.

That makes me doubt the logic in read but it works so let's just not touch it right now.

MatthieuDartiailh commented 1 year ago

Closed by #344

wintermuteger commented 1 year ago

Thanks for following up, and sorry that I didn't manage to provide a pull request.