Reading Binary from Serialport and identifying a particular message structure

조회 수: 3(최근 30일)
Samuel Olufemi Taiwo
Samuel Olufemi Taiwo 2021년 4월 7일
I am trying to read streams of binary data in from a device via the serial port.
My short code is shown below:
function gnssbinary
device = serialport ( "COM4" , 115200);
data = read (device, 50000, 'uint64' );
disp (dec2hex (data))
  1. The information I am looking or have header, Class and and ID of 0 x b5, 0 x 62, 0 x 02 and 0 x 15 in that order and the following messages should be the real information I need.
  2. I arbitrary used 5000 as the number of values ​​(in the read syntax) to be read because it is like looking for a needle in a hay stack
  3. I have been able to get 0 x b5, 0 x 62, 0 x 02 from the binary but not yet what I am looking for which should still have 0 x 15.
  4. how do I program the MATLAB to keep identify the messahe identifier in (1) above, read the messages that come after and ignore the rest until it encounters the same message identifer again and repeat the process?


Community Treasure Hunt

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

Start Hunting!

Translated by