Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39899

Re: telnet to Cognex In-Sight 4001 camera

Date 2013-02-25 17:29 +0000
From MRAB <python@mrabarnett.plus.com>
Subject Re: telnet to Cognex In-Sight 4001 camera
References <d0462043-2195-4272-b13d-fd04d1d87695@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2511.1361813390.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 2013-02-25 17:02, chris.annin@gmail.com wrote:
> Hello,  ive been struggling with this for a couple weeks now and was hoping someone might be able to help.  I have an older Cognex camera that I need to communicate with via telnet.  I can get a response from the camera when I initiate a telnet session but I dont seem to get any response when I write the user name to the camera -  I havnt been able to get any response writing anything. Im using python 2.7 and windows xp.  here is the code:
> [code]
>>>>import sys
>>>>import telnetlib
>>>>HOST = "10.31.18.21"
>>>>USER = "admin"
>>>>tn = telnetlib.Telnet(HOST)
>>>>tn.read_until("Login: ")
> "Welcome to In-Sight(R) 4001 Session 1\r\nUser:"

The returned string ends with "User:", presumably the prompt to enter
the username, which makes we wonder whether you should be reading until
"User:" instead of until "Login: ".

>>>>tn.write(USER + "\r\n")

Should you be ending that with just "\r" or just "\n" instead? (That
would be equivalent to typing the username and then pressing the Return
key.)

>>>>tn.read_until("User: ")

Haven't you already seen "User: "?

> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "C:\Python27\lib\telnetlib.py", line 319,
>      return self.read_very_lazy()
>    File "C:\Python27\lib\telnetlib.py", line 395,
>      raise EOFError, 'telnet connection closed'
> EOFError: telnet connection closed
>>>>
> [\code]
>
> if i do a read_all instead of read_until for user I just get "..." returned.  Im assuming tn.write command isnt working?  any help would be greatly appreciated.
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

telnet to Cognex In-Sight 4001 camera chris.annin@gmail.com - 2013-02-25 09:02 -0800
  Re: telnet to Cognex In-Sight 4001 camera MRAB <python@mrabarnett.plus.com> - 2013-02-25 17:29 +0000
    Re: telnet to Cognex In-Sight 4001 camera chris.annin@gmail.com - 2013-02-25 11:48 -0800
    Re: telnet to Cognex In-Sight 4001 camera chris.annin@gmail.com - 2013-02-25 11:48 -0800
  Re: telnet to Cognex In-Sight 4001 camera chris.annin@gmail.com - 2013-02-25 17:16 -0800
    Re: telnet to Cognex In-Sight 4001 camera Roy Smith <roy@panix.com> - 2013-02-25 20:44 -0500

csiph-web