Serial communication with a header and a terminator

31 views (last 30 days)
I want to send two uint16 numbers through the serial communication. The DSP wants the header and terminator to be equal to 'S' and 'E'. The command serial does not have an option for 'header' but it has an option for defining 'terminator'.
To use the header I am writing
Now in order to send the two numbers I am using:
x = int16(1);
fwrite(obj,[x x],'int16')
I know that in each fwrite command an 'E' will be sent as well. How can I avoid this? Can I just send E at the end of the commands with another fwrite?
I am using this block to configure the DSP for receiving data.
Marzieh Karami
Marzieh Karami on 17 Jun 2019
You are right! fwrite does not automatically send terminator.

Sign in to comment.

Answers (1)

Gayatri Menon
Gayatri Menon on 4 Jan 2022
Protocol Decoder block and Protocol Encoder block might be useful in such scenarios.
For more info, refer the following links
Hope this helps
Thank you


Find more on Code Generation 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!

Translated by