Trying to get serial data from AWR6843AOPEVM
    조회 수: 1 (최근 30일)
  
       이전 댓글 표시
    
Hi,
I'm using TI radar AWR6843AOPEVM, trying to get the serial data in matlab using below code.
s= serialport("COM5", 921600, 'DataBits',8);
fid=fopen("seriallog.txt",'a');
while(true)
    data=readlines(s,200,'string')
    fprintf(fid,data);
end
But When i connect this board with arduino IDE it directly display the data in serial monitor.

댓글 수: 0
답변 (1개)
  Gojo
      
 2024년 5월 12일
        Hi Vinoth,
I have a few suggestions.
The "readlines" function is probably used for reading from a file. You can check the documentation for "readlines" function here: https://www.mathworks.com/help/matlab/ref/readlines.html
For reading data from a serial port, try using "read" or "readline" functions as illustrated in the following documentation: https://www.mathworks.com/help/matlab/import_export/write-and-read-serial-port-data.html
You can try exeption handling to verify if everything is working as desired.
Also, since the "readline" function returns data as a string, you need to adjust the format specifier in "fprintf".
s = serialport("COM5", 921600, 'DataBits', 8);
fid = fopen("seriallog.txt", 'a');
% Check if the file was opened successfully
if fid == -1
    error('Failed to open file for writing.');
end
try
    while true
        data = readline(s);
        disp(data);
        fprintf(fid, '%s\n', data);
    end
catch ME
    disp(ME.message);
end
% Close the serial port and the file
delete(s);
fclose(fid);
I would also suggest to use available callback functions as shown in the following documentation: https://www.mathworks.com/help/matlab/import_export/use-events-and-callbacks-for-serial-port-communication.html
You may also find the following MATLAB Answers relevant:
I hope this helps!
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

