Read bytes from putc CCS to matlab gui
이전 댓글 표시
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
Walter Roberson
2019년 4월 4일
You should not use global s in that code. You should use
data1 = fread(obj, 1, 'uint8')
Walter Roberson
2019년 4월 4일
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
2019년 4월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 C2000 Microcontroller Blockset에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!