OT: DeviceNet via Python (was Re: It's in Python. It just _works_!)

Grant Edwards grante at visi.com
Fri Sep 3 00:23:13 EDT 2004


On 2004-09-03, Peter Hansen <peter at engcorp.com> wrote:
> Grant Edwards wrote:
>
>> A few months back I wrote a sort of a strip-chart recorder
>> program that talks DeviceNet to a measurement widget and plots
> ...
>
> Grant, could you say anything about what gadgets were involved
> that let you talk to DeviceNet with Python?  Did it have a
> serial port, or talk TCP directly, or something else?

I use a USB/CAN interface from PEAK-System Technik GmbH.
[Warning: rather sucky website designed by somebody obsessed
with frames] http://www.peak-system.com/

In the US it's distributed by Grid Connect:

http://www.gridconnect.com/usbcanin.html

I don't have the Python code talking to it under Windows yet
(that's tomorrow's project).  Apprently it doesn't come with a
stand-alone Windows device driver, but rather a DLL that you
make calls into to send/receive frames.  There are VB example
programs, so I should be able to get Python to talk to it.

In the meantime, the windows app has been talking TCP/IP to a
Linux machine that has the CAN/USB interface plugged into it.
The Linux machine runs a transparent multiplexor program that
allows multiple programs to talk to the USB CAN interface
simultaneously via TCP/IP and/or Unix domain sockets.

[Actually, the windows app was running under WinMe inside a
Win4Lin virtual machine under Linux and talking TCP/IP to the
host Linux OS which has the USB/CAN adapter plugged into it.]

FYI, the Linux driver for PEAK products has two API's for
sending and receiving CAN frames: one uses newline-terminated
ASCII hex strings and the normal read()/write() calls.  That's
the one I'm currently using, since it's so easy to multiplex
access and troubleshoot.

If you want to reduce overhead, you can make ioctl() calls to
send/receive frames in binary structures, but that would mean
that my multiplexor program would need to be smarter.  Right
now the multiplexor has no clue what the data means or what the
device is, it just shovels newline-terminated strings back and
forth between a file descriptor and some sockets.

-- 
Grant Edwards                   grante             Yow!  I want a VEGETARIAN
                                  at               BURRITO to go... with
                               visi.com            EXTRA MSG!!



More information about the Python-list mailing list