使用Pyvia控制示波器,获取的示波器截图不正常,帮忙看看哪里出错了

环境: python3.9 pyvisa
执行结果:代码能够正常执行,能够从示波器获取到图片,但图片只显示10%,其他都是乱码。

使用Pyvia控制示波器,获取的示波器截图不正常,帮忙看看哪里出错了

使用Pyvia控制示波器,获取的示波器截图不正常,帮忙看看哪里出错了

讨论数量: 3

会有可能是osc_inst.query_binary_values(COMMAND)那块获取到的值不对吗

1年前 评论
Jason990420

Chunk length (For your reference only)

If you read data from a device, you must store it somewhere. Unfortunately, PyVISA must make space for the data before it starts reading, which means that it must know how much data the device will send. However, it doesn’t know a priori.

Therefore, PyVISA reads from the device in chunks. Each chunk is 20 kilobytes long by default. If there’s still data to be read, PyVISA repeats the procedure and eventually concatenates the results and returns it to you. Those 20 kilobytes are large enough so that mostly one read cycle is sufficient.

The whole thing happens automatically, as you can see. Normally you needn’t worry about it. However, some devices don’t like to send data in chunks. So if you have trouble with a certain device and expect data lengths larger than the default chunk length, you should increase its value by saying e.g.

osc_inst.chunk_size = 3*800*600        # Display resolution 800 x 600 x 24 bits
1年前 评论

虽然不知道是什么原因,但改了下面的代码,就可以正常获取示波器的图片了。

file

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!