468,288 Members | 1,985 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,288 developers. It's quick & easy.

Python/C/RTW

14
Hey

Im in a project where i neet to execute some c functions there is generated with, matlab RTW.

So my question is:
Is there anybody there have experience with this?
Or just with execute c code og exe in python including parameters?

Thanks

/LSkov
May 24 '07 #1
3 1130
bartonc
6,596 Expert 4TB
Hey

Im in a project where i neet to execute some c functions there is generated with, matlab RTW.

So my question is:
Is there anybody there have experience with this?
Or just with execute c code og exe in python including parameters?

Thanks

/LSkov
For version 2.4 of python you can download the ctypes library module (it's included in version 2.5). With ctypes, you can call functions in DLLs and other extention modules written in C. There may also be an interface already written; I'd have to do some searching...
May 24 '07 #2
bartonc
6,596 Expert 4TB
For version 2.4 of python you can download the ctypes library module (it's included in version 2.5). With ctypes, you can call functions in DLLs and other extention modules written in C. There may also be an interface already written; I'd have to do some searching...
Turned up only 1 Open Source site: http://www.realtimelinuxfoundation.o.../projects.html
May 24 '07 #3
It is very possible to use RTW with Python. Here's some (untested) example code using the COM DLLs to get started.

You'll need win32com, the RTW COM DLLs downloadable from Mathworks, and you'll need to spend a lot of time with their API reference.

Expand|Select|Wrap|Line Numbers
  1. import win32com.client as win32comclient
  2.  
  3. # Create an object that we can use for calling COM functions
  4. RTWCOM = win32comclient.Dispatch("xpcapicom.xpcprotocol")
  5.  
  6. # Initialize the RTW protocol--this is a COM function
  7. RTWCOM.Init()
  8.  
  9. #Now connect to your target machine using TCP/IP
  10. ip = '192.168.0.1'
  11. port = '22222'
  12. RTWCOM.TcpIpConnect(ip, port)
  13.  
You'll need to do a lot more such as loading the application onto the target, but that's in the API reference.

There's probably something I left out (exactly which DLLs you need where, etc.) so let me know if you get any errors.

Peter
May 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.