Serial data cannot be read properly
7 次查看(过去 30 天)
显示 更早的评论
I am trying to get USB-to-serial communication from a Linux laptop (running Centos 6) to an RS422 device. The device passes about 1500 bytes of data in the form of three 512 byte packets every few seconds, but I have not been able to read this through Matlab.
I've used cutecom to verify that the data is in fact coming through. I have Matlab set up so that it does recognize the device when I run seriallist, and I am able to open it with:
s = serial('/dev/ttyUSB0','BaudRate',400000,'Timeout',5,'InputBufferSize',1024);
fopen(s);
This is code that has been confirmed to work on another computer, and the baudrate has been confirmed to be 400k. When I try using:
temp = fread(s,s.InputBufferSize,'uint8');
I get randomly sized data with seemingly random values. Does anyone have any recommendations on how I should proceed from here?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Install Products 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!