Serial port communication
古いコメントを表示
I have an On-Board Diagnostics (OBDII) tool that I am trying to read the values from. This tool helps me trouble codes on a car's ECU. I can use hyperterminal to read the values through the USB. When I open the terminal with COM1, baud rate of 9600 and type in 03, it returns me some value.
How do I do the same in MATLAB? Is this it or do I need to do more?
s = serial('COM1'); fopen(s) fprintf(s,'03') out = fscanf(s)
Please suggest.
採用された回答
その他の回答 (2 件)
Walter Roberson
2011 年 7 月 31 日
0 投票
What terminator does the remote system need? fprintf(s,'03') is defined as fprintf(s,'%s\n','03') which sends 03 followed by whatever terminator is configured for the port. If that terminator does not match what the remote system is expecting, you could have difficulty.
Krishna Gummadi
2011 年 7 月 31 日
0 投票
1 件のコメント
Walter Roberson
2011 年 7 月 31 日
You could set the terminator to carriage return, or you could use
fprintf(s,'%s\r', '03')
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Packages についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!