Library functions

T

Tuvas

I am writing a program that mimics a program written in C, but using
Python-supiorior techniques. The C program calles a library function,
non-open source, I only know that it sends it a command
LINUX_CAN_Open() as for a few others as well. Is there a way I can call
this function from Python without opening the code, as the library is
not open sourced (I know, a rarity with Linux libraries, but, well, it
appears not to be...)? Perhaps write a C function that acts as a
wrapper, is there a way to do it directly? Any help is much
appreciated! Thanks!
 
G

Grant Edwards

I am writing a program that mimics a program written in C, but using
Python-supiorior techniques. The C program calles a library function,
non-open source, I only know that it sends it a command
LINUX_CAN_Open() as for a few others as well.

I've successfully used the ctypes module to call Windows DLLs
(coincidentally it's to send/receive CAN messanges). According
to the ctypes docs, you can use it to call functions in Linux
libraries as well.
 
T

Tuvas

How exactly do you do that? Just to get some kind of an idea, perhaps
you could share bits of code? Thanks!
 
P

Peter Hansen

Tuvas said:
How exactly do you do that? Just to get some kind of an idea, perhaps
you could share bits of code? Thanks!

Did you check out the ctypes web site before asking? See
http://starship.python.net/crew/theller/ctypes/ and at least read
through the helpful tutorial before asking questions which are almost
certainly covered there. For example, right there near the top of the
first screen in the tutorial is an example of opening a Linux .so file...

-Peter
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,342
Members
48,018
Latest member
DelilahDen

Latest Threads

Top