CAN Packing and unpacking blocks - how do I set parameters programmatically?

There seems to be some private weirdness about the CAN Packing and unpacking blocks, as supplied with MATLAB R2009b, when used to interface with a CAN database file.
The blocks don't appear to have any mask parameter callbacks or block callbacks. There is an Init routine, of course, but that simply assumes that the SignalInfo parameter has already been filled in with signals from a selected message. However, just setting the parameters from an m-file doesn't do the trick. There is magic which happens when 'Apply' or 'OK' are clicked after choosing a specific message from a CAN database, but it's not clear what it is.
I want to automate the adding of CAN packing and unpacking blocks to a model, but just adding the block and setting the parameters doesn't seem to do the trick. I need to perform the equivalent of clicking on 'Apply' to fill in the SignalInfo parameter with the signals in the selected message - but how do I do that? As it is, I have to halt my script, click on 'Apply', and resume the script. Ugh!

 Accepted Answer

I know what you mean exactly. I once had a need to modify some customized block parameters through scripting. But the modification won't take effect. It's only because that customized block does not provide the complete API. Although I could modify the block parameter manually and then click Ok or Apply and it will take effect. We have to ask the Mathworks to provide an updated version of that customized block to complete my task.
But we didn't have problem with the CAN blocks. I know we did a complete automation from a CAN .db file to CAN receiver and transmitter blocks. It was R2007b using the blocks from canblocks.mdl. Are you using the same canblocks.mdl file in R2009b? What is your particular problem. Do you have a small example to show the problem?

3 Comments

The blocks will certainly have changed starting with
R2009b, when the new unified CAN_MESSAGE Simulink type was
introduced. I haven't checked to see whether the older
versions had the same problem; you suggest that they don't.
However, that's of limited help, as I really need to
support MATLAB 2009b on (other people's) clean installations.
Currently, your vote is added to the internal vote here for
prodding Mathworks to do the job properly (though which
versions of MATLAB will be supported this way is unclear,
and it gives us a potential patching problem with customers).
Maybe I'm being stupid, but what I
*think* is the R2007b implementation
is so far "magical" that it doesn't
even have mask parameters (though it
does have some block callbacks).
Is this evidence that I don't really
have the R2007b implementation after
all, or am I missing something?
So have you confirmed with the Mathworks that the CAN blocks in R2009b didn't provide the complete API? I don't have R2009b.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!