[newbie] trying socket as a replacement for nc

Jean Dubois jeandubois314 at gmail.com
Thu Dec 12 03:08:16 EST 2013


On Thursday, December 12, 2013 12:38:12 AM UTC+1, Conor Hughes wrote:
> Jean Dubois <jeandubois314 at gmail.com> writes:
> 
> 
> 
> > I have an ethernet-rs232 adapter which allows me to connect to a
> 
> > measurement instrument by means of netcat on a linux system.
> 
> > e.g. entering nc 10.128.59.63 7000
> 
> > allows me to enter e.g.
> 
> > *IDN?
> 
> > after which I get an identification string of the measurement
> 
> > instrument back.
> 
> > I thought I could accomplish the same using the python module "socket"
> 
> > and tried out the sample program below which doesn't work however:
> 
> 
> 
> In what way does it not work? Do you not get any data? Do you get the
> 
> wrong data? Does your program block at a point which you do not
> 
> understand?
> 
> 
> 
> Probably more to the point, are you sure you are sending exactly the
> 
> same data as you did with netcat? netcat running with stdin a terminal
> 
> sends data line-by-line, and includes the newline in the data that it
> 
> sends. You didn't send a newline in your example.
Thanks for the reply, I changed the line you mentioned to
s.send('*IDN?\n')
Rerunning the program then shows me as response the first time
Received:
The measurement instrument gives a beep indicating it receives something
which is however not recognized als normal input

Running the script a  second time, the program hangs.. and I have to reboot the adapter

kind regards,
jean



More information about the Python-list mailing list