Simulink Startfcn Callback fails when using serial() function
2 次查看(过去 30 天)
显示 更早的评论
Matlab 2014a. I have this following function:
function s = open_serial_port()
s = serial('COM2');
set(s,'BaudRate',115200,'Databits',8,'Parity','none','Stopbit',1,'Terminator','LF');
fopen(s);
fprintf(s,'*IDN?')
out = fscanf(s);
disp(out);
Calling it from the Command Window works fine. Calling it from Simulink Startfcn callback does not work, with the following error:
Open failed: Port: COM2 is not available. Available ports: COM1.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
For some reason COM2 is available from Command Window but not from Simulink Callback?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!