Does serial () detect a virtual COM port

9 ビュー (過去 30 日間)
Sreedu
Sreedu 2011 年 2 月 9 日
Hi,
I want to know if the serial() function in MATLAB can get data from virtual COM ports. My system's COM port is not working so I use a USB to RS232 adapter. But now an error comes at serial() that this port is not available or does not exist. This was not the case with the original COM port.

回答 (1 件)

Ankit Desai
Ankit Desai 2011 年 2 月 9 日
You should be able to get a USB-to-Serial adaptor to show up in MATLAB. Remember to restart MATLAB to see the new port show up.
The following command can list details on the serial ports found and ones that are available:
serialInfo = instrhwinfo('serial');
You might want to make sure that your serial port shows up in the "AvailableSerialPorts" field of the "serialInfo" structure obtained above.
A word of caution though that not all USB-to-Serial adaptors emulate an on-board serial port exactly. The better the adaptor emulate the on-board serial port, the better performance (reliable and robust) you will get.
Hope this helps,
-Ankit
  3 件のコメント
Ankit Desai
Ankit Desai 2011 年 4 月 22 日
Sorry I forgot to mention that command is only available with Instrument Control Toolbox.
To answer the question whether serial function works with virtual COM ports, yes it will as explained here: http://www.mathworks.com/matlabcentral/answers/3360-can-i-use-matlab-to-communicate-with-a-serial-port-and-or-a-virtual-serial-usb-to-serial-port
To find out ports available (and their names) you will have to depend on operating system and use device manager.
Shawn Chang
Shawn Chang 2012 年 6 月 21 日
Hi Ankit Desai, I am using the virtual usb port too. I can't obtained the port by command "instrfind" but yet I can obtained port through the "s=instrhwinfo('Serial')".
s=instrhwinfo('Serial')
s =
AvailableSerialPorts: {2x1 cell}
JarFileVersion: 'Version 2.9.0'
ObjectConstructorName: {2x1 cell}
SerialPorts: {2x1 cell}
s.AvailableSerialPorts
ans =
'COM5'
'COM6'
May I know how can I access the COM6, using the serial programming or other method? Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeUse COM Objects in MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by