Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76130 > unrolled thread
| Started by | c1223 <camilocelyg@gmail.com> |
|---|---|
| First post | 2014-08-12 11:36 -0700 |
| Last post | 2014-08-13 08:25 -0700 |
| Articles | 15 — 10 participants |
Back to article view | Back to comp.lang.python
Begginer in python trying to load a .dll c1223 <camilocelyg@gmail.com> - 2014-08-12 11:36 -0700
Re: Begginer in python trying to load a .dll Chris Angelico <rosuav@gmail.com> - 2014-08-13 04:44 +1000
Re: Begginer in python trying to load a .dll Skip Montanaro <skip@pobox.com> - 2014-08-12 13:48 -0500
Re: Begginer in python trying to load a .dll Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-12 19:52 +0100
Re: Begginer in python trying to load a .dll Chris Kaynor <ckaynor@zindagigames.com> - 2014-08-12 11:55 -0700
Re: Begginer in python trying to load a .dll c1234 py <camilocelyg@gmail.com> - 2014-08-12 11:56 -0700
Re: Begginer in python trying to load a .dll Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-08-12 11:58 -0700
Re: Begginer in python trying to load a .dll Chris Angelico <rosuav@gmail.com> - 2014-08-13 05:09 +1000
Re: Begginer in python trying to load a .dll c1234 py <camilocelyg@gmail.com> - 2014-08-12 12:13 -0700
Re: Begginer in python trying to load a .dll Laurent Pointal <laurent.pointal@laposte.net> - 2014-08-19 18:44 +0200
Re: Begginer in python trying to load a .dll "ElChino" <elchino@cnn.cn> - 2014-08-19 19:46 +0200
Re: Begginer in python trying to load a .dll Christian Gollwitzer <auriocus@gmx.de> - 2014-08-12 21:16 +0200
Re: Begginer in python trying to load a .dll c1234 py <camilocelyg@gmail.com> - 2014-08-12 12:25 -0700
Re: Begginer in python trying to load a .dll Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-12 21:17 +0100
Re: Begginer in python trying to load a .dll c1234 py <camilocelyg@gmail.com> - 2014-08-13 08:25 -0700
| From | c1223 <camilocelyg@gmail.com> |
|---|---|
| Date | 2014-08-12 11:36 -0700 |
| Subject | Begginer in python trying to load a .dll |
| Message-ID | <3dade0aa-55ca-4e52-af08-8104e9edf4c3@googlegroups.com> |
Hi, Im working in the development of a program based in python that allow us to contrl a spectometer. The spectometer has an .dll file. The idea is to work through this dll and operate the spectometer. The name of the .dll is AS5216.dll. I've trying with ctype, but it doesn't work. I'm begginer in python. All the comments are useful to me.
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-13 04:44 +1000 |
| Message-ID | <mailman.12892.1407869083.18130.python-list@python.org> |
| In reply to | #76130 |
On Wed, Aug 13, 2014 at 4:36 AM, c1223 <camilocelyg@gmail.com> wrote: > Im working in the development of a program based in python that allow us to contrl a spectometer. The spectometer has an .dll file. The idea is to work through this dll and operate the spectometer. > The name of the .dll is AS5216.dll. I've trying with ctype, but it doesn't work. > I'm begginer in python. > All the comments are useful to me. What have you tried, exactly? What does "it doesn't work" mean? Interfacing with a DLL is a potentially very hard and complex job (although it might turn out to be really easy - depends what the DLL's doing). We can't simply give you an answer right here, without knowing heaps about the DLL you're working with - where it came from, whether this is homework or a real-world problem, etc, etc, etc. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Skip Montanaro <skip@pobox.com> |
|---|---|
| Date | 2014-08-12 13:48 -0500 |
| Message-ID | <mailman.12893.1407869289.18130.python-list@python.org> |
| In reply to | #76130 |
On Tue, Aug 12, 2014 at 1:36 PM, c1223 <camilocelyg@gmail.com> wrote: > I've trying with ctype, but it doesn't work. Can you post a small example of how you're trying to use cypes? I don't think a full example would be necessary, but knowing the API of one or two functions and how you're trying to call them from Python would be useful. Just as the off-chance your DLL was written in C++... I don't think you can interface with ctypes directly. I think you would have to write a little shim DLL which exposes a C-compatible API. Skip
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-12 19:52 +0100 |
| Message-ID | <mailman.12894.1407869583.18130.python-list@python.org> |
| In reply to | #76130 |
On 12/08/2014 19:36, c1223 wrote: > Hi, > Im working in the development of a program based in python that allow us to contrl a spectometer. The spectometer has an .dll file. The idea is to work through this dll and operate the spectometer. > The name of the .dll is AS5216.dll. I've trying with ctype, but it doesn't work. > I'm begginer in python. > All the comments are useful to me. > Please help us to help you. Stating "it doesn't work" is of no use. Show us your code, what you expected to happen and what actually happened. If you get a traceback cut and paste all of it into your message. State what version of Python you have and your OS. Sure seeing dll we can surmise Windows but which one? For further advice on how to put your question(s) together see "The SSCCE - Short, Self Contained, Correct (Compilable), Example" at http://sscce.org/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Chris Kaynor <ckaynor@zindagigames.com> |
|---|---|
| Date | 2014-08-12 11:55 -0700 |
| Message-ID | <mailman.12895.1407869744.18130.python-list@python.org> |
| In reply to | #76130 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Aug 12, 2014 at 11:48 AM, Skip Montanaro <skip@pobox.com> wrote: > Just as the off-chance your DLL was written in C++... I don't think > you can interface with ctypes directly. I think you would have to > write a little shim DLL which exposes a C-compatible API. > You should be able to use ctypes with a C++ library, you'd just need to know how your C++ compiler handles name mangling. Typically, changes are made to accommodate classes, namespaces, and function overloads. Of course, if you were to change to a different compiler (possibly including a different version) or made minor tweaks to the functions, you'd have to update all the Python code to use the new name mangling scheme. Hmm...On second thought, maybe just only using functions exports with "extern C" would be easier - or just using a C compiler. Chris
[toc] | [prev] | [next] | [standalone]
| From | c1234 py <camilocelyg@gmail.com> |
|---|---|
| Date | 2014-08-12 11:56 -0700 |
| Message-ID | <b6940b3e-c5b0-4f73-a830-32a3aae82654@googlegroups.com> |
| In reply to | #76130 |
On Tuesday, August 12, 2014 3:36:17 PM UTC-3, c1234 py wrote:
> Hi,
>
> Im working in the development of a program based in python that allow us to contrl a spectometer. The spectometer has an .dll file. The idea is to work through this dll and operate the spectometer.
>
> The name of the .dll is AS5216.dll. I've trying with ctype, but it doesn't work.
>
> I'm begginer in python.
>
> All the comments are useful to me.
I'm using this
>>import ctypes
hllDll=ctypes.WinDLL("C:\\AS5216.dll")
hllApiProto = ctypes.WINFUNCTYPE (ctypes.c_int,ctypes.c_void_p,
ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
hllApiParams = (1, "p1", 0), (1, "p2", 0), (1, "p3",0), (1, "p4",0),
hllApi = hllApiProto (("HLLAPI", hllDll), hllApiParams)
p1 = ctypes.c_int (1)
p2 = ctypes.c_char_p (sessionVar)
p3 = ctypes.c_int (1)
p4 = ctypes.c_int (0)
hllApi (ctypes.byref (p1), p2, ctypes.byref (p3), ctypes.byref (p4))
Thanks
[toc] | [prev] | [next] | [standalone]
| From | Rob Gaddi <rgaddi@technologyhighland.invalid> |
|---|---|
| Date | 2014-08-12 11:58 -0700 |
| Message-ID | <20140812115854.19cdccad@rg.highlandtechnology.com> |
| In reply to | #76138 |
On Tue, 12 Aug 2014 11:56:37 -0700 (PDT)
c1234 py <camilocelyg@gmail.com> wrote:
> On Tuesday, August 12, 2014 3:36:17 PM UTC-3, c1234 py wrote:
> > Hi,
> >
> > Im working in the development of a program based in python that allow us to contrl a spectometer. The spectometer has an .dll file. The idea is to work through this dll and operate the spectometer.
> >
> > The name of the .dll is AS5216.dll. I've trying with ctype, but it doesn't work.
> >
> > I'm begginer in python.
> >
> > All the comments are useful to me.
>
>
> I'm using this
>
>
> >>import ctypes
> hllDll=ctypes.WinDLL("C:\\AS5216.dll")
>
>
> hllApiProto = ctypes.WINFUNCTYPE (ctypes.c_int,ctypes.c_void_p,
> ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
> hllApiParams = (1, "p1", 0), (1, "p2", 0), (1, "p3",0), (1, "p4",0),
>
>
> hllApi = hllApiProto (("HLLAPI", hllDll), hllApiParams)
>
> p1 = ctypes.c_int (1)
> p2 = ctypes.c_char_p (sessionVar)
> p3 = ctypes.c_int (1)
> p4 = ctypes.c_int (0)
> hllApi (ctypes.byref (p1), p2, ctypes.byref (p3), ctypes.byref (p4))
>
>
Great. And that fails in what way, on which line, with what error message?
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-08-13 05:09 +1000 |
| Message-ID | <mailman.12896.1407870555.18130.python-list@python.org> |
| In reply to | #76139 |
On Wed, Aug 13, 2014 at 4:58 AM, Rob Gaddi <rgaddi@technologyhighland.invalid> wrote: > Great. And that fails in what way, on which line, with what error message? And, is that the entire program? Because if it is, then I can see at least one problem, a NameError. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | c1234 py <camilocelyg@gmail.com> |
|---|---|
| Date | 2014-08-12 12:13 -0700 |
| Message-ID | <e2f1ec37-df79-4397-8370-efb91a763287@googlegroups.com> |
| In reply to | #76141 |
On Tuesday, August 12, 2014 4:09:13 PM UTC-3, Chris Angelico wrote:
> On Wed, Aug 13, 2014 at 4:58 AM, Rob Gaddi
>
> <rgaddi@technologyhighland.invalid> wrote:
>
> > Great. And that fails in what way, on which line, with what error message?
>
>
>
> And, is that the entire program? Because if it is, then I can see at
>
> least one problem, a NameError.
>
>
>
> ChrisA
This appear in the terminal:
>>> runfile('C://Python Scripts')
File "C:\\sitecustomize.py", line 585, in runfile
execfile(filename, namespace)
File "C://Sin título 38.py", line 19, in <module>
hllApi = hllApiProto (("HLLAPI", hllDll), hllApiParams)
AttributeError: function 'HLLAPI' not found
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
[toc] | [prev] | [next] | [standalone]
| From | Laurent Pointal <laurent.pointal@laposte.net> |
|---|---|
| Date | 2014-08-19 18:44 +0200 |
| Message-ID | <53f37ef0$0$5108$426a74cc@news.free.fr> |
| In reply to | #76142 |
c1234 py wrote:
> This appear in the terminal:
>
>
>>>> runfile('C://Python Scripts')
> File "C:\\sitecustomize.py", line 585, in runfile
> execfile(filename, namespace)
> File "C://Sin título 38.py", line 19, in <module>
> hllApi = hllApiProto (("HLLAPI", hllDll), hllApiParams)
> AttributeError: function 'HLLAPI' not found
>>>> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
So you must find the (exact) name(s) exported by the DLL.
On Linux ther is objdump.
On Windows there is dumpbin
http://msdn.microsoft.com/en-us/library/c1h23y6c%28v=vs.100%29.aspx
On Windows, google also found this graphical tool:
http://www.dependencywalker.com/
A+
PS. If you have a C header file, it may be more easy to correctly build
the ctype mapping (and if its not too big and filled of private
property code, show it).
[toc] | [prev] | [next] | [standalone]
| From | "ElChino" <elchino@cnn.cn> |
|---|---|
| Date | 2014-08-19 19:46 +0200 |
| Message-ID | <lt02hl$9v5$1@dont-email.me> |
| In reply to | #76577 |
"Laurent Pointal" <laurent.pointal@laposte.net> wrote: > On Windows there is dumpbin > http://msdn.microsoft.com/en-us/library/c1h23y6c%28v=vs.100%29.aspx > > On Windows, google also found this graphical tool: > http://www.dependencywalker.com/ PEdump is also a great tool: http://www.wheaty.net/pedump.zip Includes source too. --gv
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2014-08-12 21:16 +0200 |
| Message-ID | <lsdp62$enh$1@dont-email.me> |
| In reply to | #76130 |
Am 12.08.14 20:36, schrieb c1223: > Hi, Im working in the development of a program based in python that > allow us to contrl a spectometer. The spectometer has an .dll file. > The idea is to work through this dll and operate the spectometer. The > name of the .dll is AS5216.dll. I've trying with ctype, but it > doesn't work. I'm begginer in python. All the comments are useful to > me. For sure this DLL will come with a header file for C. You could pass it through SWIG and see if it generates a useful Python module. You need a C compiler for that route, though. Christian
[toc] | [prev] | [next] | [standalone]
| From | c1234 py <camilocelyg@gmail.com> |
|---|---|
| Date | 2014-08-12 12:25 -0700 |
| Message-ID | <dde2ab54-3ae1-4fb6-9048-85eae8e93943@googlegroups.com> |
| In reply to | #76143 |
El martes, 12 de agosto de 2014 16:16:21 UTC-3, Christian Gollwitzer escribió: > Am 12.08.14 20:36, schrieb c1223: > > > Hi, Im working in the development of a program based in python that > > > allow us to contrl a spectometer. The spectometer has an .dll file. > > > The idea is to work through this dll and operate the spectometer. The > > > name of the .dll is AS5216.dll. I've trying with ctype, but it > > > doesn't work. I'm begginer in python. All the comments are useful to > > > me. > > > > For sure this DLL will come with a header file for C. You could pass it > > through SWIG and see if it generates a useful Python module. You need a > > C compiler for that route, though. > > > > Christian How can i pass it through a SWIG?, i don't know that and what it mean?
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-12 21:17 +0100 |
| Message-ID | <mailman.12899.1407874663.18130.python-list@python.org> |
| In reply to | #76145 |
On 12/08/2014 20:25, c1234 py wrote: > El martes, 12 de agosto de 2014 16:16:21 UTC-3, Christian Gollwitzer escribió: >> Am 12.08.14 20:36, schrieb c1223: >> >>> Hi, Im working in the development of a program based in python that >> >>> allow us to contrl a spectometer. The spectometer has an .dll file. >> >>> The idea is to work through this dll and operate the spectometer. The >> >>> name of the .dll is AS5216.dll. I've trying with ctype, but it >> >>> doesn't work. I'm begginer in python. All the comments are useful to >> >>> me. >> >> >> >> For sure this DLL will come with a header file for C. You could pass it >> >> through SWIG and see if it generates a useful Python module. You need a >> >> C compiler for that route, though. >> >> >> >> Christian > > > How can i pass it through a SWIG?, i don't know that and what it mean? > Start here http://www.swig.org/ which you could easily have found for yourself, as I did by using a search engine. Also would you please access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | c1234 py <camilocelyg@gmail.com> |
|---|---|
| Date | 2014-08-13 08:25 -0700 |
| Message-ID | <0014387b-9168-4b7f-820e-d0cff91ad763@googlegroups.com> |
| In reply to | #76149 |
Thanks a lot. El martes, 12 de agosto de 2014 17:17:26 UTC-3, Mark Lawrence escribió: > On 12/08/2014 20:25, c1234 py wrote: > > > El martes, 12 de agosto de 2014 16:16:21 UTC-3, Christian Gollwitzer escribi�: > > >> Am 12.08.14 20:36, schrieb c1223: > > >> > > >>> Hi, Im working in the development of a program based in python that > > >> > > >>> allow us to contrl a spectometer. The spectometer has an .dll file. > > >> > > >>> The idea is to work through this dll and operate the spectometer. The > > >> > > >>> name of the .dll is AS5216.dll. I've trying with ctype, but it > > >> > > >>> doesn't work. I'm begginer in python. All the comments are useful to > > >> > > >>> me. > > >> > > >> > > >> > > >> For sure this DLL will come with a header file for C. You could pass it > > >> > > >> through SWIG and see if it generates a useful Python module. You need a > > >> > > >> C compiler for that route, though. > > >> > > >> > > >> > > >> Christian > > > > > > > > > How can i pass it through a SWIG?, i don't know that and what it mean? > > > > > > > Start here http://www.swig.org/ which you could easily have found for > > yourself, as I did by using a search engine. > > > > Also would you please access this list via > > https://mail.python.org/mailman/listinfo/python-list or read and action > > this https://wiki.python.org/moin/GoogleGroupsPython to prevent us > > seeing double line spacing and single line paragraphs, thanks. > > > > -- > > My fellow Pythonistas, ask not what our language can do for you, ask > > what you can do for our language. > > > > Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web