?? Modules for GPIB and Ethernet ??
Roy Smith
roy at panix.com
Fri Nov 5 08:48:36 EST 2004
In article <21240387.0411050533.4d145e2a at posting.google.com>,
justinhsia at yahoo.com (Chaser) wrote:
> I have an equipment that's controlled through ethernet. (The control
> program is currently written in C++.) I guess my really difficulty
> is, how do I send commmands to that devise through ethernet using
> Python?
You havn't given enough information to give a good answer, but I'll take
a shot.
First, you need to know what kind of protocol your device talks. It's
virtually certain that the device implements some kind of custom
application-level protocol on top of some standard transport layer such
as TCP/IP. Assuming that's the case, you need to:
1) Find the documentation for the application-level protocol it talks.
2) Find out the IP address (or hostname) of the device.
>From within Python, you will need to create a socket, connect the socket
to your device using the connect() method, and then use the send() and
recv() methods to talk to the device. You'll need to implement the
application-layer protocol yourself.
The details of how to use sockets in Python (i.e. connect(), send(),
recv(), etc) are documented in "7.2 socket -- Low-level networking
interface" of the Python Library Reference. To really understand what
section 7.2 is talking about, however, you need to have a general feel
for how network communication works in general. Fortunately, the
introduction to section 7.2 contains some pointers to some good general
reference books.
More information about the Python-list
mailing list