How can i avoid lag when receive and transmit through serial port in GUI

4 views (last 30 days)
Hello all!
Recently,i made a GUI to communicate with other device.There exists some lag problem i can not figure out. The receive method is normal
set(scom,'BaudRate',BaudRate,'BytesAvailableFcnMode', 'byte','BytesAvailableFcnCount', 21,...
'BytesAvailableFcn', @BytesReceive);
The GUI works well if only receive data from device.The Data is about 10times per second continuesly.It means GUI should excute the receive callback per 100ms. When i use the getpts in axes,it will occur Interruption during mouse point selection if i dont'close the serial port and reopen after selected complete. The KeypressFcn also occur a very serious delay(I want use it to change the slider value and send value,so when i press the key it keep change the value continuously).
I think the reason is per 100ms, the GUI have jump into the BytesReceive function,so the other function such as slider getpts have to wait for the BytesReceive function excute complete.I wonder if there is any methods to solve this problem.
I would greatly appreciate if you kindly give me some some advice.

Answers (0)

Categories

Find more on 语言基础知识 in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!