MATLAB: How to use the pack and unpack functionality with SCI transmit and receive blocks in Target Support Package TC2 3.1 (R2008b)

Target Support Package TC2

I would like to send and receive signals of mixed data types with my TC2 target using the SCI transmit and receive blocks. As there are no PACK and UNPACK blocks available with TC2 library, I tried using the BYTE PACK and BYTE UNPACK blocks with TC6 but I receive the following error message:
Error evaluating registered method 'Start' of M-S-Function 'c2000hostsci_rx' in 'pcjunk2/SCI Receive'. Attempt to reference field of non-structure array
I receive the same error when I try to use the UDP PACK and UNPACK blocks as well. How else can I pack and unpack data when communicating with my target?

Best Answer

Blocks from target-specific libraries are generally not supported accross
targets and hence it is not possible to use PACK and UNPACK blocks from the xPC or TC6 library with TC2 blocks. As stated in the summary, the pack and unpack functionality is not available for the Target Support Package TC2 3.1 (R2008b) SCI Transmit and Receive blocks. Thus, they cannot be used with mixed data types.
As a workaround, to send mixed data-types to the target, use Simulink blocks that perform bit manipulation to represent all data inputs as chunks of the same data-types before transmitting and similarly perform bit-arithmetic at the target to reconvert them back to original data-types.
The attached model has an example on implementing this PACK-UNPACK functionality for Simulink blocks.