device.list
device.list
Function
Returns the list of open devices still visible to the current program.
Syntax
device.list()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Array | Returns an array of opened device information objects. |
Device information field
Each object in the array represents an open device that is still visible to the current program.
| Field | Type | Must exist | Description |
|---|---|---|---|
| type | String | Yes | The device type, currently serial. |
| port | String | Yes | The serial port name used when opening the device. |
| baud_rate | Int | Yes | The baud rate used when opening the serial port. |
| closed | Bool | Yes | Whether the underlying device connection has been closed. true means it has been closed and cannot continue to read or write. |
Example
// After opening a serial port, device.list() can show the device handles held by the current process. port = device.open({type: 'serial', port: 'COM3'}) items = device.list() result = items[0].closed // Output: false print result port.close()
Notes
- Weak references that have been released will be cleaned up when listing.
-
device.list()only lists devices that have been opened in the current process and are still referenced, not a full serial port scan of the system.