Importing a 3rd Party windows DLL for use within th Python

Discussion in 'Python' started by lee.walczak@gmail.com, Apr 4, 2008.

  1. Guest

    Hi,

    I have recently started learing how to code/script in Python which I
    am realy enjoying. I am new to this game as my background is RF/HW
    design engineer so coding is not my first skillset , so please bare
    with me!

    I am a little lost with how to procede on this problem. I need to
    write a python script enabling me to comunnicate routines to a pico
    ADC212 oscilloscope. I have been provided with a windows DLL & a
    header filefrom the manufacturer.
    Is it possible for someone to provide the information on the steps
    necessary to access this DLL and treat it like any other pyd library?
    Maybe there is already a tutorial available for performing this task?
    Is this task straight forward?

    Look forward to 'a' response!

    B.Regards,

    Lee

    Feel free to request more information if you feel it is necessary.
     
    , Apr 4, 2008
    #1
    1. Advertising

  2. sturlamolden Guest

    On Apr 5, 12:58 am, wrote:

    > Is it possible for someone to provide the information on the steps
    > necessary to access this DLL and treat it like any other pyd library?
    > Maybe there is already a tutorial available for performing this task?
    > Is this task straight forward?


    Short answer: Read the ctypes tutorial and reference.

    http://python.net/crew/theller/ctypes/tutorial.html
    http://python.net/crew/theller/ctypes/reference.html


    Other options:
    - Write a pyd wrapper manually in C
    - Write a pyd wrapper using Pyrex or Cython
    - Write a pyd wrapper using Swig
    - Write a pyd wrapper using Boost.Python or PyCXX
    - Inline C++ using scipy.weave
     
    sturlamolden, Apr 5, 2008
    #2
    1. Advertising

  3. Robert Kern Guest

    wrote:
    > Hi,
    >
    > I have recently started learing how to code/script in Python which I
    > am realy enjoying. I am new to this game as my background is RF/HW
    > design engineer so coding is not my first skillset , so please bare
    > with me!
    >
    > I am a little lost with how to procede on this problem. I need to
    > write a python script enabling me to comunnicate routines to a pico
    > ADC212 oscilloscope. I have been provided with a windows DLL & a
    > header filefrom the manufacturer.
    > Is it possible for someone to provide the information on the steps
    > necessary to access this DLL and treat it like any other pyd library?
    > Maybe there is already a tutorial available for performing this task?
    > Is this task straight forward?


    It depends on how complicated the library is. For a first stab, I recommend
    using ctypes. ctypes lets you load the DLL and call its functions in pure Python
    without having to write an extension module (pyd) first. ctypes comes with
    Python 2.5 already; if you have Python 2.4, you can install it separately.

    http://python.net/crew/theller/ctypes/

    You may eventually want to write an extension module. Here is the tutorial:

    http://docs.python.org/ext/ext.html

    There are a couple of tools to make this task easier. I happen to like Cython
    for things like this:

    http://cython.org/

    One large benefit of using ctypes instead of building an extension is that you
    do not have to compile anything. When wrapping binary-only DLLs on Windows,
    compiling and linking correctly are often the largest hurdles.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Apr 5, 2008
    #3
  4. Guest

    Thankyou kindly for all the details you have provided. IT is nice to
    know that there is a community to help.
    I will let you know how I get on!

    Many Thanks,

    Lee
     
    , Apr 5, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VUtQb3N0aWU=?=

    COM Interop problem with 3rd Party DLL using C# under ASP.NET

    =?Utf-8?B?VUtQb3N0aWU=?=, Sep 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    835
    =?Utf-8?B?VUtQb3N0aWU=?=
    Sep 23, 2004
  2. =?Utf-8?B?c3RyYXp6?=
    Replies:
    0
    Views:
    529
    =?Utf-8?B?c3RyYXp6?=
    Jan 27, 2006
  3. Michael Williams
    Replies:
    0
    Views:
    335
    Michael Williams
    Nov 14, 2005
  4. Replies:
    0
    Views:
    303
  5. Dennis Lee Bieber
    Replies:
    0
    Views:
    129
    Dennis Lee Bieber
    Jun 26, 2013
Loading...

Share This Page