Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61624 > unrolled thread
| Started by | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| First post | 2013-12-11 15:08 -0800 |
| Last post | 2013-12-13 00:43 +0100 |
| Articles | 6 on this page of 46 — 13 participants |
Back to article view | Back to comp.lang.python
[newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-11 15:08 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-11 15:20 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 00:28 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 13:23 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 19:23 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 19:32 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 03:03 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 03:56 -0800
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-13 08:35 +0000
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 04:20 -0800
Re: [newbie] trying socket as a replacement for nc rusi <rustompmody@gmail.com> - 2013-12-13 09:04 -0800
Re: [newbie] trying socket as a replacement for nc rusi <rustompmody@gmail.com> - 2013-12-13 09:09 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-14 05:11 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-14 05:14 -0800
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-14 13:29 +0000
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-16 01:40 -0800
Re: [newbie] trying socket as a replacement for nc Ervin Hegedüs <airween@gmail.com> - 2013-12-16 11:04 +0100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-12 14:16 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-13 01:23 +1100
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 13:27 -0800
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:06 +0000
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-14 17:24 -0800
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-15 15:15 +0000
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-15 10:51 -0500
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 03:04 +1100
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-15 12:44 -0500
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-15 22:42 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 09:48 +1100
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-13 08:58 +1100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:10 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-14 03:19 +1100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:57 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-14 04:05 +1100
Re: [newbie] trying socket as a replacement for nc 88888 Dihedral <dihedral88888@gmail.com> - 2013-12-16 04:38 -0800
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 23:59 +1100
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-16 09:03 -0500
Re: [newbie] trying socket as a replacement for nc 88888 Dihedral <dihedral88888@gmail.com> - 2013-12-18 23:20 -0800
Re: [newbie] trying socket as a replacement for nc Dave Angel <davea@davea.name> - 2013-12-12 19:52 -0500
Re: [newbie] trying socket as a replacement for nc Conor Hughes <conorh@conorh.net> - 2013-12-11 15:38 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 00:08 -0800
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-12 19:21 +1100
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 01:21 -0800
Re: [newbie] trying socket as a replacement for nc Alister <alister.ware@ntlworld.com> - 2013-12-12 14:05 +0000
Re: [newbie] trying socket as a replacement for nc Alister <alister.ware@ntlworld.com> - 2013-12-12 14:05 +0000
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-12 14:34 +0000
Re: [newbie] trying socket as a replacement for nc Christian Gollwitzer <auriocus@gmx.de> - 2013-12-13 00:43 +0100
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-12-12 19:21 +1100 |
| Message-ID | <mailman.3970.1386836496.18130.python-list@python.org> |
| In reply to | #61677 |
On Thu, Dec 12, 2013 at 7:08 PM, Jean Dubois <jeandubois314@gmail.com> wrote:
> Thanks for the reply, I changed the line you mentioned to
> s.send('*IDN?\n')
See if there's a newline issue - you might need \r\n here.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-12 01:21 -0800 |
| Message-ID | <d92123da-f4c1-45a0-ad64-4ec4f881d388@googlegroups.com> |
| In reply to | #61679 |
On Thursday, December 12, 2013 9:21:32 AM UTC+1, Chris Angelico wrote:
> On Thu, Dec 12, 2013 at 7:08 PM, Jean Dubois <jeandubois314@gmail.com> wrote:
>
> > Thanks for the reply, I changed the line you mentioned to
>
> > s.send('*IDN?\n')
>
>
>
> See if there's a newline issue - you might need \r\n here.
>
>
>
> ChrisA
I changed it as you suggested to:
s.send('*IDN?\r\n')
unfortunately this doesn't change the result, first run give as response:
Received:
second run makes the program hang and the adapter needs rebooting
kind regards,
jean
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-12-12 14:05 +0000 |
| Message-ID | <2pjqu.23361$lc4.20507@fx26.am4> |
| In reply to | #61690 |
On Thu, 12 Dec 2013 01:21:27 -0800, Jean Dubois wrote:
> On Thursday, December 12, 2013 9:21:32 AM UTC+1, Chris Angelico wrote:
>> On Thu, Dec 12, 2013 at 7:08 PM, Jean Dubois <jeandubois314@gmail.com>
>> wrote:
>>
>> > Thanks for the reply, I changed the line you mentioned to
>>
>> > s.send('*IDN?\n')
>>
>>
>>
>> See if there's a newline issue - you might need \r\n here.
>>
>>
>>
>> ChrisA
>
> I changed it as you suggested to:
>
> s.send('*IDN?\r\n')
>
> unfortunately this doesn't change the result, first run give as
> response:
> Received:
> second run makes the program hang and the adapter needs rebooting
>
> kind regards,
> jean
you probably need to use something like wireshark to see what is actually
happening and compare it to a good connection in the normal way.
--
Save energy: Drive a smaller shell.
[toc] | [prev] | [next] | [standalone]
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Date | 2013-12-12 14:05 +0000 |
| Message-ID | <Aojqu.22$kI.14@fx01.am4> |
| In reply to | #61690 |
On Thu, 12 Dec 2013 01:21:27 -0800, Jean Dubois wrote:
> On Thursday, December 12, 2013 9:21:32 AM UTC+1, Chris Angelico wrote:
>> On Thu, Dec 12, 2013 at 7:08 PM, Jean Dubois <jeandubois314@gmail.com>
>> wrote:
>>
>> > Thanks for the reply, I changed the line you mentioned to
>>
>> > s.send('*IDN?\n')
>>
>>
>>
>> See if there's a newline issue - you might need \r\n here.
>>
>>
>>
>> ChrisA
>
> I changed it as you suggested to:
>
> s.send('*IDN?\r\n')
>
> unfortunately this doesn't change the result, first run give as
> response:
> Received:
> second run makes the program hang and the adapter needs rebooting
>
> kind regards,
> jean
you probably need to use something like wireshark to see what is actually
happening and compare it to a good connection in the normal way.
--
Save energy: Drive a smaller shell.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-12 14:34 +0000 |
| Message-ID | <mailman.3994.1386858905.18130.python-list@python.org> |
| In reply to | #61714 |
On 12/12/2013 14:05, Alister wrote: > > you probably need to use something like wireshark to see what is actually > happening and compare it to a good connection in the normal way. > You've sent this twice old chap, you've a configuration issue somewhere I'd guess :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2013-12-13 00:43 +0100 |
| Message-ID | <l8dhmv$qk4$1@dont-email.me> |
| In reply to | #61624 |
Am 12.12.13 00:08, schrieb Jean Dubois:
> 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:
> import socket
> host = '10.128.59.63'
> port = 7000
> size = 10
The socket library advises to use a small power of two like 1024; 10
seems very small.
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect((host,port))
> s.send('*IDN?')
\n or \r\n is missing, you found this by yourself - look into the device
manual, which one is correct
> data = s.recv(size)
It may be, that you simply need to wait for some time after the write,
before you read. And then before the device is ready, you close the
connection. If this is the case, try waiting a short time in between and
use socket.sendall() instead of socket.send()
> s.close()
Maybe you need to read twice?
> Can anyone here tell me how to do it properly?
The most proper way is to use asynchronous IO; never done this in python
before, check this:
http://docs.python.org/2/library/asyncore.html#asyncore-example-basic-http-client
Christian
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.python
csiph-web