I am trying to control a signal generator using python. I just need to change the amplitude and frequency.`my code is below:
HOST = "184.108.40.206"
timeout = 5
PORT = 5023
tn = telnetlib.Telnet(HOST, PORT , timeout)
I've run your code against a listening
nc, and Python 2.7 complained that the call to
telnetlib.Telnet(HOST, PORT , timeout, Debug) was wrong - the parameter
Debug should have been omitted.
Actually, in the documentation the Debug parameter isn't present:
Telnet.open(host[, port[, timeout]])
Connect to a host. The optional second argument is the port number, which defaults to the standard Telnet port (23). The optional
timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used).
Do not try to reopen an already connected instance. Changed in version 2.6: timeout was added.
Once fixed that, however, the commands were sent identical by telnet in raw mode and by your code. It could be some weird timing thing, but apart from that it should work.
Just to be safe I'd still run a tcpdump if I were you.
You aren't terminating the commands, so they are not getting executed.
.write() does not auto-terminate commands.
tn.write('FREQ 1.92ghz' + "\n")
Also, wait for an answer before closing, just in case.
tn.read_until("some answer", timeout) tn.close()