[PythonCE] serial port access

Luke Dunstan coder_infidel at hotmail.com
Wed Jun 21 15:05:50 CEST 2006


You need to use the wide-character variants of Windows APIs, i.e. 
CreateFileW

Luke

----- Original Message ----- 
From: "Benjamin McBride" <benjamin.mcbride at gmail.com>
To: <pythonce at python.org>
Sent: Wednesday, June 21, 2006 4:54 AM
Subject: Re: [PythonCE] serial port access


Thanks Gonzalo for your help.  I have read both the ctypes and
microsoft documentation.  My understanding is that I need to use the
CreateFile API function from the coredll to get a handle to the comm
port.  When I use ctypes:

>>> windll.coredll.CreateFile

I get an AttributeError saying the CreateFile function is not found.
Ironically, the ReadFile, WriteFile, and CloseHandle functions are all
found.

Am I just missing something simple here?

Ben

On 6/20/06, Gonzalo Monzón <gmc at serveisw3.net> wrote:
> Have you read the ctypes docs?
>
> http://starship.python.net/crew/theller/ctypes/tutorial.html
>
> You have to read the Microsoft docs too, search what dynamic libraries
> to use and what functions to call. Study the example I posted, you have
> to call these functions using ctypes:
>
> (openfile, readfile, writefile...)
>
> Don't know if somebody has implemented serial access using ctypes as to
> post an example, read the docs, first you need to understand how ctypes
> work -for that you should know or learn what C variable types are and
> understand it almost a little bit, then the codeproject example will
> come in handy- otherwise could be hard to code... Though any ctypes
> example handling file or stream data may help you. Though pyserial uses
> ctypes too, so you could have a look to the sources. The differences are
> you have to use straight windows api calls, and pyserial calls a helper
> library wich should use windows api's for windows platform.
>
> I have to code serial access too in the next weeks, but don't have the
> time now to get my hands in it. If you are not in hurry I could post an
> example when done.
>
> Gonzalo.
>
>
> Benjamin McBride escribió:
>
> >I've got ctypes installed.  However, I have not been able to find any
> >examples of how I might use ctypes for serial port access.  Any
> >suggestions would be appreciated.
> >
> >Thanks,
> >
> >Ben
> >
> >On 6/20/06, Gonzalo Monzón <gmc at serveisw3.net> wrote:
> >
> >
> >>Hi Benjamin,
> >>
> >>You can use ctypes for direct access to serial ports via windows apis
> >>(openfile, readfile, writefile...)
> >>
> >>Note that manufacturers can have specific implementations, even they
> >>must agree to PPC implementation, but you can found small differences.
> >>
> >>http://www.codeproject.com/system/simpleserialcomm.asp
> >>
> >>Regards,
> >>Gonzalo
> >>
> >>
> >>Benjamin McBride escribió:
> >>
> >>
> >>
> >>>    Hi All,
> >>>
> >>>    I need to access the serial port for my PPC application.  I have 
> >>> been
> >>>    unable to locate information on this.  I'm using Python 2.4.3 and 
> >>> PPC
> >>>    2003.  Previously I've used pyserial, but it appears that pyserial 
> >>> does
> >>>    not work on Windows CE.
> >>>
> >>>    Thanks for any suggestions,
> >>>
> >>>    Ben McBride
> >>>    bdm7935 at ksu.edu
> >>>_______________________________________________
> >>>PythonCE mailing list
> >>>PythonCE at python.org
> >>>http://mail.python.org/mailman/listinfo/pythonce
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >_______________________________________________
> >PythonCE mailing list
> >PythonCE at python.org
> >http://mail.python.org/mailman/listinfo/pythonce
> >
> >
> >
>
>
_______________________________________________
PythonCE mailing list
PythonCE at python.org
http://mail.python.org/mailman/listinfo/pythonce


More information about the PythonCE mailing list