pythontelnetoscilloscope

Cannot read answer from telnet communication


I'm currently working on a little script that I found on GitHub, made by RoGeorge : https://github.com/RoGeorge/DS1054Z_screen_capture. This script should allows me to get a screenshot of my digital storage oscilloscope (DS1054z from RIGOL). So I've putted this script on my Raspberry Pi to have use it, but once everything was correctly setup, the script seems to receive nothing from my scope. This is surprising because : I can ping the scope and I can communicate with him by the telnet command on the terminal. So I've made a little script (that I will put just below) that permit me to see if the Telnet library for Python work or not. Result : It do not work when we went to read, but it's send without problem.

import telnetlib
tn = telnetlib.Telnet('193.168.1.2','5555')
tn.set_debuglevel(100)
tn.write("*idn?")
tn.read_until('\n',1)

Output :

>> Telnet(193.168.1.2,5555): send '*idn?'
>> ''

Is my code correct ? Did anyone have an idea of what is happening ? Thanks in advance !

PS : I've tested the script from GitHub and mine just above on my Windows 10 PC also. Don't work.


Solution

  • When you send a command you have to end it with a newline like this:

    tn.write("*idn?\n")