su=serialportused
su : | serial in use |
serialportused
This function, serialportused
, is designed to identify serial ports that are currently in use on a system. It is part of the SolidGeometry library, specifically introduced in version 5.1, and is categorized under auxiliary procedures.
The function serialportused
does not take any input parameters. It operates without requiring any arguments from the user.
The function returns a variable su
, which is a list of serial ports that are currently in use.
The function utilizes two key MATLAB functions: serialportlist("all")
and serialportlist("available")
.
serialportlist("all")
: This command retrieves a list of all serial ports available on the system, regardless of their current status (in use or available).serialportlist("available")
: This command retrieves a list of serial ports that are currently available for use, meaning they are not occupied by any process.The core operation of the function is performed by the setdiff
function:
su = setdiff(serialportlist("all"), serialportlist("available"));
The setdiff
function calculates the difference between the two lists: all serial ports and available serial ports. The result is a list of serial ports that are in use, as these are the ports present in the "all" list but absent from the "available" list.
To use the function, simply call it without any arguments:
serialportused
This will return the list of serial ports that are currently in use.
The function is related to other functions such as raamboterminal
and serialportlist
, which may be used for further serial port management and operations.
Overall, the serialportused
function provides a straightforward method to identify which serial ports are occupied, aiding in debugging and resource management tasks.