How to unpack data with Byte Unpacking

27 visualizaciones (últimos 30 días)
Inna Forsiuk
Inna Forsiuk el 24 de Mzo. de 2021
Respondida: Dimitri MANKOV el 7 de Jul. de 2022
Hello,
I would be happy if somebody could explain to me how to set the parameter properly in the Byte Unpacking block.
I am using Simulink Real-time, where the communication is going through a TCP socket. From TCP Receive block the data is unpacked into uint8 (which is the setting for default). I need to unpack the data via Byte Unpacking with int16. Could somebody tell me please what I have to put as the output dimension for int16?
In the attachment, I send the model to clarify the model vision.

Respuesta aceptada

Dimitri MANKOV
Dimitri MANKOV el 7 de Jul. de 2022
Hi Inna,
The "Output port dimension" parameter defines the size of the outputs produced by the "Byte Unpacking" block, as explained in the documentation. For example, suppose you receive a vector of 15 uint8 packets as an input, and you know that these packets contain the following signals:
  • 2x single (2x 32 bits / 2x 4 bytes)
  • 3x int16 (3x 16 bits / 3x 2 bytes)
  • 1x uint8 (1x 8 bits / 1x 1 byte)
You would configure the "Byte Unpack" block as follows:
  • Output data type: {['single'], ['int16'], ['uint8']}
  • Output dimension: {[2],[3],[1]}
This would generate 3 output ports for the "Byte Unpacking" block, the first being a vector of 2 single values, the second a vector of 3 int16 values and the third a uint8 signal.
In your case, you go from uint8 to int16, so the output dimension in your case would be the input dimension divided by 2.
I hope this is helpful!
Dimitri

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by