Read bytes from putc CCS to matlab gui
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 4 Apr. 2019
You should not use global s in that code. You should use
data1 = fread(obj, 1, 'uint8')
Walter Roberson
am 4 Apr. 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
am 4 Apr. 2019
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!