Push button callback in an active while loop instance within a toggle button callback ?

1 次查看(过去 30 天)
Hello,
My application requires me to use multiple COM (serial) ports for communicating with various devices in my experiment. To start the acquisition, I have a toggle button that opens all ports and starts reading values from the devices. This button is on a while loop as long as the toggle button value is 1. I also have a few push buttons in my GUI with associated edit boxes where the user enters the value they wish to change, and the "update" push button sends a write signal to the devices.
At the moment, I face the following problems:
- If I define the update code in a callback associated with the push button, the program crashes because the callback function doesn't have information on the fopen(...) commands that were used to open the communication ports. If I define an fopen(...) in the callback, it crashes again because my fclose(...) commands are following the while loop (when the user presses the toggle button again to stop data acquisition).
- If I try to use, within the while loop, a property function such as
if get.pushbuttonValue == 1
communicate with device and update value...;
end
The above doesn't do anything, because I think the push button value changes to 1 only instantaneously? Not sure.
Q1) Is there a good and easy way to make changes on other callbacks when the while loop (when the toggle button is ON) is running?
Can someone explain this with a simple code?
Thanks K

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by