Stymied on this - fopen('ser') hangs Matlab!
Show older comments
I am helpless with this one, I have a digital Pulse oximeter which acts as a COM device - connected through USB port. When it connects, I see on the device manager COM4 port activated with it.
But when I write
ser=serial('COM4');
fopen(ser);
pause(1);
data=fread(ser,ser.BytesAvailable);
disp(done);
fclose(ser);
The Matlab application goes into an endless busy mode. The only two ways to get out is cntrl-alt-del, or On the device, is an option to switch the USB on or off manually. By default the USB mode is on, but if I switch it to off manually, I can now access Matlab.
To rerun the above I have to give
delete(instrfind);
Surprisingly, the following works:
1. replace ser.BytesAvailable by 512
and
2. Put USB mode 'off; then run the Matlab program; while it is waiting put the USB mode to 'On' manually on the device. Then I get 512 bytes of data out.
Whenever I replace 512 with BytesAvailable I get error "SIZE has to be greater than 0". Also wheever I run the code with USB 'On', fopen hangs Matlab. On debugging I found that the place where the code hangs is at fopen(getobject1) in fopen.m
Any ideas suggestions. Please help. Thanks. rajn
Accepted Answer
More Answers (0)
Categories
Find more on Test and Measurement 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!