Skip to content

Commit

Permalink
Merge pull request #96 from MattEttus/master
Browse files Browse the repository at this point in the history
return port info to user so it can be parsed.  Also fix a bug.
  • Loading branch information
sjkelly authored Dec 15, 2023
2 parents 231d738 + 6fb7458 commit 0a39ade
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/LibSerialPort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 0a39ade

Please sign in to comment.