By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

Python/C/RTW

P: 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
Share this Question
Share on Google+
3 Replies


bartonc
Expert 5K+
P: 6,596
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
Expert 5K+
P: 6,596
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

P: 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.