Serial data cannot be read properly

7 visualizzazioni (ultimi 30 giorni)
Daniel Ramos
Daniel Ramos il 29 Mag 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?

Risposte (0)

Categorie

Scopri di più su Install Products in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by