Hi all,
Does anyone have any code they could share with me on how to get all active Comports and list them in a combo list so i can have it so a user can select them from the list
List All Comport in a Combo list
Re: List All Comport in a Combo list
try this (you need to be root or member of dialout):
- Attachments
-
- CheckSerialPorts.gambas.tar.gz
- (2.33 KiB) Downloaded 232 times
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: List All Comport in a Combo list
Hi PJ,
That works perfectly but i get a Error saying "Port must be closed first" but if you click ignore it works
how would i add that function to my own app now? as the file only had the exe in it and not the source code
That works perfectly but i get a Error saying "Port must be closed first" but if you click ignore it works
how would i add that function to my own app now? as the file only had the exe in it and not the source code
Re: List All Comport in a Combo list
very good question ... i've deleted that one yesterday without thinking
rewriting it
EDIT:
try out if it works ...
rewriting it
EDIT:
try out if it works ...
Public oRS232 As SerialPort
Public Function GetActivePorts() As String[]
Dim ReturnValue As New String[]
'----------------------------------------
Dim sShell As String
Dim aSerPorts As String[]
oRS232 = New SerialPort
Shell "ls -m /dev/ttyS*" To sShell
Replace(sShell, "\n", "")
aSerPorts = Split(sShell, ",")
For Each sSP As String In aSerPorts
oRS232.PortName = Trim(sSP)
Try oRS232.Open()
If oRS232.Status = Net.Active Then ReturnValue.add(sSP)
oRS232.Close
Next
'----------------------------------------
Return ReturnValue
Catch
' Do some Error Handling if you like
End
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: List All Comport in a Combo list
Thank-you PJ I shall add that to my project
For this to list USB Ports would I just change the tty to USB?
For this to list USB Ports would I just change the tty to USB?
Re: List All Comport in a Combo list
i did not have rs232 or usb2seriell converter so i'm not shure but i guess it will maybe named ttyUSBxx ???
-
- Posts: 363
- Joined: Wednesday 2nd December 2020 12:11am
- Location: Northampton, England
- Contact:
Re: List All Comport in a Combo list
Ill try it and let you know
Some of my Printers are USB so I can test it
Some of my Printers are USB so I can test it