Read bytes from putc CCS to matlab gui
Show older comments
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 Comments
Walter Roberson
on 4 Apr 2019
You should not use global s in that code. You should use
data1 = fread(obj, 1, 'uint8')
Walter Roberson
on 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
on 4 Apr 2019
Accepted Answer
More Answers (0)
Categories
Find more on C2000 Microcontroller Blockset in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!