フィルターのクリア

Serial communication error between mbed and MATLAB

4 ビュー (過去 30 日間)
Nithin M
Nithin M 2019 年 5 月 19 日
I have a code to send data serially from mbed(LPC1768) to MATLAB(2018a). mbed reads the connected GPS values and being sent to MATLAB continuously.
Iam using the following line,
printf("%lf,%lf,%lf,%lf\n", easting, northing, speed_main, heading_main); to send data from mbed. (this is inside a continously running while loop).
while data not available from gps I have set the 'easting, northing, speed_main, heading_main' variable values to zero.
At MATLAB end am reading it inside a while loop which is running continuously. Am able to read data correctly from MATLAB end for few iterations but going forward it throws error as follows ."Matching failure in format. The format specified for conversion, '%f, %f, %f, %f', is incorrect". Why it is happening? any solution to read it every iterations without error? is this a timing issue? I tried with different delays 0.1, 0.2 sec etc at both end but not solved? (GPS, mbed to pc baud are also set to same baud rate 9600.)
MATLAB end code
while(true)
mbed = serial('COM7', ...
'BaudRate', 9600, ...
'Parity', 'none', ...
'DataBits', 8, ...
'StopBits', 1);
fopen(mbed);
pause(0.5);
values = fscanf(mbed, '%f, %f, %f, %f');
fclose(mbed);
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by