alternative for "DriverNames" under Win32

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rozek
Posts: 151
Joined: Mon Jun 19, 2006 2:29 pm
Contact:

alternative for "DriverNames" under Win32

Post by rozek » Sun Apr 13, 2008 8:03 am

Hello!

How do I enumerate the available serial ports under Windows, MacOS and Linux? Is there an alternative for "DriverNames" which only works under MacOSX?

Thanks in advance for any help!
Kind regards,

Andreas Rozek

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Wed Apr 16, 2008 4:31 pm

you could try something like:

put empty into tAvailibleComPorts
repeat with tCount = 1 to 9 --rev can only open COM1: to COM9:

put "COM" & tCount & ":" into tComPort --make up the com port name
open file tComPort for read --try to open the com port
if tComPort is among the lines of the OpenFiles then put tComPort & return after tAvailibleComPorts --If the com port is opened add it to the list of Availible com ports
close file tComPort --free the com port (optional)
next repeat
end repeat

Answer tAvailibleComPorts --Display a message with the list of availile com ports, one on each line.

rozek
Posts: 151
Joined: Mon Jun 19, 2006 2:29 pm
Contact:

Post by rozek » Wed Apr 23, 2008 5:52 pm

Thank your very much for your effort!

Now I have to find out if it is safe to "open" a serial port just to see if it exists...
Kind regards,

Andreas Rozek

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Post by n.allan » Thu Apr 24, 2008 9:41 am

It won't be a problem.

If the COM port is not "safe" to open the result will contain "cannot open that file" else it will be empty.

rozek
Posts: 151
Joined: Mon Jun 19, 2006 2:29 pm
Contact:

Post by rozek » Sat May 03, 2008 6:41 am

Thank you very much for your posting!
Kind regards,

Andreas Rozek

Post Reply