MATLAB Answers

Is there an equivalent serialbreak() function with the new serialport class in MATLAB 2020b?

8 views (last 30 days)
Matthew Feemster
Matthew Feemster on 23 Oct 2020
Commented: Walter Roberson on 27 Oct 2020
MATLAB is recommending the switch to serialport as opposed to serial. With the old serial class, you could send a serialbreak() command. With the new serialport() class, I cannot locate a similar functionality. Is there a way to do this? Thanks.
% Old way.
mbed = serial('COM9');
% New way.
mbed = serialport('COM9',9600);
% How do I send serial break with this new class?

Answers (1)

Pratyush Roy
Pratyush Roy on 27 Oct 2020
Hi Matthew,
As of MATLAB R2019b there is no builtin function to send a serial break to the 'serialport' object. Instead this will have to be done manually by sending 0 bits to the device for a certain amount of time, depending on the device. For example you can manually write 0s for the necessary amount of time:
Hope this helps !!
  1 Comment
Walter Roberson
Walter Roberson on 27 Oct 2020
NO this will not work!! Every byte written this way will be properly framed with start and stop bits, and it will just be data transfer!
break is holding the line at 0 V for more than one character time including start and stop bits. This is not a possible character: any possible character would switch to mark within that time.
That has a suggestion that I had long forgotten. Switch to a much lower baud rate, preferably at least 10 times slower. Send 0. This will hold the bits beyond the time expected by the receiver.
Note that this technique might have problems if the receiver is in autobaud.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by