Read bytes from putc CCS to matlab gui
Afficher commentaires plus anciens
Hello, i have this code :
s.BytesAvailableFcnMode = 'byte';
s.BytesAvailableFcnCount = 1;
s.BytesAvailableFcn = {@mycallback,handles};
function mycallback(obj,event,handles)
global s;
data1 = fread(s,1); //read 1 byte
end
The question's "when i use 2 times putc, how can i read 2 bytes at the same time, one for data1 and one for data2 ???"
3 commentaires
Walter Roberson
le 4 Avr 2019
You should not use global s in that code. You should use
data1 = fread(obj, 1, 'uint8')
Walter Roberson
le 4 Avr 2019
It is a lot of effort to read two bytes at the same time. It requires using multiple threads and multiple devices, and using thread synchronization, and might require grabbing effective control over the host in order to do real-time work. It is ugly.
It is a lot easier to read two bytes on one device sequentially.
HANH TRAN
le 4 Avr 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur C2000 Microcontroller Blockset dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!