Info

此问题已关闭。 请重新打开它进行编辑或回答。

Handling serial data transfers

1 次查看(过去 30 天)
Glenn
Glenn 2013-6-13
关闭: MATLAB Answer Bot 2021-8-20
I have Matlab reading serial data for a device by using callbacks. This is important as it allows the user interface to remain responsive while updating the display with information from the serial data stream. However, there are times when I need to transfer large amounts of data from the device. The only way to handle this is to run in a tight loop for good performance. The problem is that there seems to be no way to turn off the callback feature so that I can just read in a loop. If I leave the callback enabled Matlab seems to cache all of the callbacks that aren't serviced while in the loop and eventually crashes. I start the session like this:
comport = ['COM' get(handles.edit1,'String')];
handles.s = serial(comport,'BaudRate',115200,'DataBits',8,'Timeout',5);
handles.s.BytesAvailableFcnCount = 1;
handles.s.BytesAvailableFcnMode = 'byte';
handles.s.BytesAvailableFcn = {@serialCallback,handles,hObject};
When the device goes into transfer mode I need to disable the callback. How do I do this?

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by