Is there an equivalent serialbreak() function with the new serialport class in MATLAB 2020b?
Mostra commenti meno recenti
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');
fopen(mbed);
serialbreak(mbed,1);
% New way.
mbed = serialport('COM9',9600);
% How do I send serial break with this new class?
Risposte (2)
Pratyush Roy
il 27 Ott 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:
write(s,zeros(1,amount),"uint8")
Hope this helps !!
5 Commenti
Walter Roberson
il 27 Ott 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.
https://stackoverflow.com/questions/1279478/rs-232-break-signal
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.
Mike Kokko
il 2 Lug 2021
Modificato: Mike Kokko
il 2 Lug 2021
Has this been addressed yet? I'm trying to transition from serial to serialport and this is a show stopper. The baud rate trick doesn't seem to be working.
Mike Kokko
il 23 Mag 2022
@Pratyush Roy do you know if there is a fix yet for transitioning serialbreak() to the new serialport interface? I need to send an actual serial break to a device (not just framed packets of zeros) and am concerned that we will lose this capability when the serial interface is removed from MATLAB. Thanks.
Walter Roberson
il 24 Mag 2022
Mike Koko:
You will need to raise this as a technical support case to emphasize to Mathworks that it is needed.
The new interface is, in my opinion, not currently suitable for controlling a serial port.
There was a time when I wrote modem control software, and data transfer software over dialup. I was a systems administrator for an ISP with international nodes. The current serialport() interface would not be usable for that kind of purpose.
Mike Kokko
il 24 Mag 2022
@Walter Roberson Thank you very much, I will do that.
Michael
il 20 Nov 2023
0 voti
This issue has been fixed in R2023b: https://www.mathworks.com/help/matlab/ref/serialport.serialbreak.html
Categorie
Scopri di più su Serial and USB Communication in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!