How can I read the whole input buffer of a serial port object?
Afficher commentaires plus anciens
I am communicating with a device via rs-232 and I would like to read the whole iput buffer of the serial object at once.
What I already tried was:
s = serial('com1');
fopen(s);
fscanf(s,'%f',s.bytesavailable);
So when I run the code I only get the last value instead of the whole input buffer.
Do you have a clue what the issue could be?
Réponse acceptée
Plus de réponses (1)
Valentino Tomasic
le 22 Juin 2015
0 votes
1 commentaire
Walter Roberson
le 22 Juin 2015
Is the input terminated somehow? linefeed? Or even just a comma between entries? If so then you should be programming a bytesavailablefcn callback. That callback can grab values from the serial port and store them away for a later run of the processing loop. For example you could keep a circular buffer, such as is shown blog or file exchange
Catégories
En savoir plus sur Desktop dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!