List of available com ports
5 views (last 30 days)
Show older comments
I am working on matlab 2010. I need to get the list of comports using 'seriallist' command. But it shows error telling 'seriallist function not found'. But this function works in 2018 version. But why not in 2010?
0 Comments
Answers (2)
Geoff Hayes
on 28 Aug 2018
Abhishek - according to seriallist, this function was introduced in r2017a. In your older version of MATLAB, try using the FEX submission Get Available COM Ports.
Seiran Petikian
on 22 Apr 2019
Edited: Seiran Petikian
on 22 Apr 2019
Unfortunately seriallist doesnt work below 2017 and also it has another problem: it shows all COM port and you still need to guess which is the one I connected my favorit Cypress USB device. Here it is how I resolved that problem for myself. You need to copy small program listComPorts.exe written by Viacheslav Frolov into your working directory . You can download it from github .
Example of outputof listComPort from within Matlab:
>> system('listComPorts.exe')
COM16 - Microsoft - BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\8&829E717&0&000000000000_0000000C
COM15 - Microsoft - BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}_VID&00010039_PID&1582\8&829E717&0&1606292214D2_C00000006
COM10 - Cypress COM Port - USB\VID_04B4&PID_4717\00000000
COM# <-> COM# - Vyacheslav Frolov - ROOT\COM0COM\0000
Because you know your device manufacturer and/or VIP or PID you can select correct one. And from here you can automate your connection using grep. Here how I'm finding my FPGA virtual com port driver (Cypress one in list above):
system('listcomports.exe | grep VID_04B4 > s.tmp');
fl=fopen('s.tmp'); COMPORT=fscanf(fl,'%s',1); fclose(fl);
s1=serial(COMPORT); fopen(s1);
First line finding the line with VID_04B4 in text and saves the line in temporary file s.tmp
second line gets the first word of saved file and third line opens your "favorit" com port without entering any info manually.
All you need correct search word in grep. Obviously it works with any version of Matlab. I'm using the same in Octave.
Sorry for late...
Regards ,
Seiran Petikian
0 Comments
See Also
Categories
Find more on Debugging and Analysis 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!