473,569 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

It's in Python. It just _works_!

A few months back I wrote a sort of a strip-chart recorder
program that talks DeviceNet to a measurement widget and plots
the received data in more-or-less real time using the Gnuplot
module. It was written on Linux system with absolutely no
thought given to portability. It's nothing big (about 650
lines of code).

Today, just for fun, I decide to try to run it under Win32.
After installing the Numeric and Gnuplot modules, I only had to
make 1-line changes to two places in the code, and it started
working.

Apparently, the file descriptor you get from a socket object
under Win32 can't be used with os.read() and os.write()? I
couldn't find anywhere in the docs that said so, but I sure
couldn't get it to work. At least not under WinMe.

--
Grant Edwards grante Yow! RELAX!!... This
at is gonna be a HEALING
visi.com EXPERIENCE!! Besides,
I work for DING DONGS!
Jul 18 '05 #1
13 2973
Grant Edwards wrote:
Today, just for fun, I decide to try to run it under Win32.
After installing the Numeric and Gnuplot modules, I only had to
make 1-line changes to two places in the code, and it started
working.


I was similarly surprised when, after writing ZOE (a simple 3D rendering
engine using OpenGL) for Linux, I decided on a whim to try it on Windows
(since I don't use Windows for anything other than playing games).
After installing PyOpenGL, a fairly involved simulation worked with
absolutely no hitches. In my case, I didn't even have to change one
line of code!

Now, granted, the whole purpose of OpenGL is platform independence. But
my experience has been that hardly matters when you're trying to get
things working on Windows ...

--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ I can paint a portrait of myself / I will call me a black Mona
Lisa -- Lamya
Jul 18 '05 #2
[Grant Edwards]
...
Apparently, the file descriptor you get from a socket object
under Win32 can't be used with os.read() and os.write()? I
couldn't find anywhere in the docs that said so, but I sure
couldn't get it to work. At least not under WinMe.


Socket handles and file descriptors are disjoint concepts in Windows
(any flavor), and aren't interchangeable in any context.
Jul 18 '05 #3
On 2004-09-03, Tim Peters <ti********@gma il.com> wrote:
[Grant Edwards]
...
Apparently, the file descriptor you get from a socket object
under Win32 can't be used with os.read() and os.write()? I
couldn't find anywhere in the docs that said so, but I sure
couldn't get it to work. At least not under WinMe.


Socket handles and file descriptors are disjoint concepts in Windows
(any flavor), and aren't interchangeable in any context.


I think I knew that at one time. IIRC, Windows was so far
behind the curve when it came to networking that TCP/IP was
implimented by the third-party "WinSock" library duct-taped
onto the side of Windows. Surely MS must have added real
networking support to the OS itself eventually?

--
Grant Edwards grante Yow! Jesuit priests are
at DATING CAREER DIPLOMATS!!
visi.com
Jul 18 '05 #4
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?

-Peter
Jul 18 '05 #5
On 2004-09-03, Peter Hansen <pe***@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!!
Jul 18 '05 #6
On Fri, 03 Sep 2004 02:24:23 +0000, Grant Edwards wrote:
I think I knew that at one time. IIRC, Windows was so far
behind the curve when it came to networking that TCP/IP was
implimented by the third-party "WinSock" library duct-taped
onto the side of Windows. Surely MS must have added real
networking support to the OS itself eventually?


Yes, someone had a look at BSD code...

--
Christopher

Jul 18 '05 #7
Grant Edwards wrote:
On 2004-09-03, Peter Hansen <pe***@engcorp. com> wrote:
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.

[snip]

Thanks so much for that detailed description! I've
filed it for reference the next time we have to talk
CAN to something, and passed it on to a number of
people.

Our own approach used a CAN4USB device from Zanthic
Technologies, and talked to a Windows DLL using calldll.
We had also experimented with a plug-in card from a
German company (different one, I think), but that
didn't work out as well.

I'm curious if anyone has yet contrived a working
solution for both Linux and Windows... Zanthic
didn't have a Linux driver for theirs, and I don't
know what the API would have been to talk to it
from Linux.

-Peter
Jul 18 '05 #8
In article <41************ ***@alcyone.com >,
Erik Max Francis <ma*@alcyone.co m> wrote:
Grant Edwards wrote:
Today, just for fun, I decide to try to run it under Win32.
After installing the Numeric and Gnuplot modules, I only had to
make 1-line changes to two places in the code, and it started
working.


I was similarly surprised when, after writing ZOE (a simple 3D rendering
engine using OpenGL) for Linux, I decided on a whim to try it on Windows
(since I don't use Windows for anything other than playing games).
After installing PyOpenGL, a fairly involved simulation worked with
absolutely no hitches. In my case, I didn't even have to change one
line of code!


Ditto for a couple of wxPython-based programs that I
wrote on Win32 (I haven't gotten around to installing OpenGL
on my Linux machines.) Handed to the users, who use mostly
OS-X and Linux, the programs did just work.

Regards. Mel.
Jul 18 '05 #9
Tim Peters <ti********@gma il.com> wrote in message news:<ma******* *************** *************** *@python.org>.. .
[Grant Edwards]
...
Apparently, the file descriptor you get from a socket object
under Win32 can't be used with os.read() and os.write()? I
couldn't find anywhere in the docs that said so, but I sure
couldn't get it to work. At least not under WinMe.


Socket handles and file descriptors are disjoint concepts in Windows
(any flavor), and aren't interchangeable in any context.


Not exactly. In WIN32 API WriteFile() one can use SOCKET and file
handle returned by CreateFile(). os.read() uses handles returned by
open(), which on WIN32 are not the same as returned by CreateFile.
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6020
by: Thomas Nücker | last post by:
Hello! I am using the python dll within a visual-c++ project. In the project i am also handling python scripts. Since i want to use some message-boxes i want to have the opportunity to import modules in the script. Now there is the question: How do i have to configure / compile the python-dll so i can use the tkinter-module or the...
4
3431
by: anonymous | last post by:
i'm looking to start learning python. could someone recommend a good beginner's book for me? thanks. -------------------------------------------------------------------- For free web access to 50,000+ newsgroups, please visit
1
1598
by: Vbfoo Bar | last post by:
Hello, To implement a Zope intranet on a linux RedHat ES 3, I had to install a Python 2.3.4 that I have compiled myself. I would like to compare the respective performance of this python interpreter and that of the Python provided by RedHat (just a little bench program would be sufficient) as I suspect the binary Python 2.3.4 (or just...
2
420
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 240 open ( -1) / 2655 closed (+15) / 2895 total (+14) Bugs : 766 open ( +0) / 4514 closed (+22) / 5280 total (+22) RFE : 155 open ( +1) / 131 closed ( +0) / 286 total ( +1) New / Reopened Patches ______________________
2
13363
by: Steve Doody | last post by:
When I add #include <Python.h> to a header file, GCC tells me, No such file or directory. Am trying to learn how to combine C++ and Python. Using SuSE 9.0 Linux, 2.4.21-231-default GCC 3.3.1 Python 2.3.4 (Just built on the box successfully) My problem is frustratingly simple and I am sure is because I am ignorant of correct GCC setup...
8
2228
by: Xah Lee | last post by:
the Python regex documentation is available at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html Note that, i've just made the terms of use clear. Also, can anyone answer what is the precise terms of license of the official python documentation? The official python.org doc site is not clear. Note also, that the regex...
69
3202
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of this pep would be to make it impossible to use the name 'print' in a backward compatible manner. Indeed, if a program is to compile in both Python...
27
2210
by: scott | last post by:
Hi all, I have been looking at the various programming languages available. I have programed in Basic since I was a teenager and I also have a basic understanding of C, but I want something better. Can anybody tell me the benefits and weaknesses of using Python? -- Your friend,
34
6772
by: pamela fluente | last post by:
I would like to hear your *opinion and advice* on best programming practice under .NET. Given that several time we cannot change: MyCollection.Clear into the instantiation of a NEW MyCollection because we make orphan some needed reference, I notice also that several times I can "equivalently" decide whether a
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.