From: PsyKo W on 14 Apr 2010 14:21 Hello, I'm developping an way to access network traffic using Simulink. I have a configured Block, which is masking a subsystem : Ground -----> Fcn ------> Output The Fcn is a "Fcn Block" from Simulink. It calls a C MEX Function to access data. At first, the Mex function is called with a param 'Start' to start listening, Then I just acces the data by calling the same Mex Function with a 'Read' param, and some other params. Everything works fine in Simulink. I see my value, and when I send different value over the network, I can see this change at the out port of my block. The strange thing is when I compile it using RTW. The compilation seems to work fine, since it produces an Exe file. But when I start this Exe file, the output given to the generated .mat file is wrong. Actually it is exactly the same output as the block was giving in Simulink during compilation. If I run the Exe file, and send new data over the network, nothing changes. I still see the value of the compilation. So my question is : does RTW compiler makes an optimization, assuming my Fcn is a constant or something ? my Fcn does not use the input port. Maybe it can have some consequences...I don't know. Another question comes into my mind. Is there a way to report error while running the RTW Executable ? Like showing an error in the launched console ? I use mexPrintf, which works while in Matlab, but not in RTW. This will make debugging easier. Thanks a lot.
From: PsyKo W on 14 Apr 2010 14:43 Self answering, but in the doc http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/fcn.html I read : The expression can include one or more of these components: Workspace variables — Variable names that are not recognized in the preceding list of items are passed to MATLAB for evaluation. Matrix or vector elements must be specifically referenced (e.g., A(1,1) instead of A for the first element in the matrix). Would that mean that calling a custom function in a generated Exe will fail ? Since it cannot access Matlab ? The thing is,I cannot use a S Function for this, because S-Functions because I need to initialize some global variables within the function, with value from Matlab, before the first Read is made...
|
Pages: 1 Prev: Random numbers (integers) from a to b? Next: Reading and modifying XML file using MATLAB |