From 6fb7458d710c133e77ef7fee7aae3bc0d50409ff Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Sun, 10 Dec 2023 20:18:19 -0800 Subject: [PATCH] return port info to user so it can be parsed. --- src/LibSerialPort.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/LibSerialPort.jl b/src/LibSerialPort.jl index 6d199b5..876c290 100644 --- a/src/LibSerialPort.jl +++ b/src/LibSerialPort.jl @@ -284,25 +284,27 @@ end list_ports([nports_guess::Integer])` Print a list of currently visible ports, along with some basic info. +Also return that info in an array so that user can parse and look for the right port to use. `nports_guess` provides the number of ports guessed. Its default is `64`. """ function list_ports(;nports_guess::Integer=64) ports = sp_list_ports() + portinfo = [] for port in unsafe_wrap(Array, ports, nports_guess, own=false) - port == C_NULL && return + port == C_NULL && break println(sp_get_port_name(port)) println("\tDescription:\t", sp_get_port_description(port)) println("\tTransport type:\t", sp_get_port_transport(port)) + push!(portinfo,[sp_get_port_name(port),sp_get_port_description(port),sp_get_port_transport(port)]) + println(portinfo) end - sp_free_port_list(ports) - return nothing + return portinfo end - """ get_port_list([nports_guess::Integer])