Serial data cannot be read properly

1 view (last 30 days)
Daniel Ramos
Daniel Ramos on 29 May 2018
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?

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!