Removing first data string from real-time serial data

Hello, I am trying to read real-time serial data from a CAN bus interface using 'fscanf'. The parameters of the string are fixed. The problem is that usually, the first line of the string appears to be incomplete/broken or has some fault codes. This affects the allocation of data into rows and columns I've used in my program according to their position in the string. I want to omit the first line of the string during every iteration. The sample data string is attached below with an indication of broken string (first line of text).
'˜D=37:0E2=00:0D9=69;005AB0DC
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB140
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB1A4
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB208
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB26C
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB2D0
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB334
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB398
:0CC=0000:0CD=0000:0CF=0000:0D0=0000:00D=37:0E2=00:0D9=69;005AB3FC
Could someone help me out with this?

2 件のコメント

Walter Roberson
Walter Roberson 2018 年 3 月 5 日
Is that a cell array of character vectors? Is it a single character vector with embedded carriage return and newline characters?
Prajwal Ramakrishna
Prajwal Ramakrishna 2018 年 3 月 6 日
編集済み: Prajwal Ramakrishna 2018 年 3 月 6 日
Yes it is a single character vector with embedded CR and newline characters. Every iteration I want the string to start from ':0CC=... excluding the previous broken lines. Its not a problem even if the first 2 lines get discarded.

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2018 年 3 月 5 日

0 投票

If you are reading with fscanf() then just do an fgetl() on the interface and discard the result.

2 件のコメント

Walter Roberson
Walter Roberson 2018 年 3 月 6 日
A(1:find(A == char(10), 1)) = [];
Prajwal Ramakrishna
Prajwal Ramakrishna 2018 年 3 月 8 日
It worked! Thank you, Mr.Walter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by