list of serial port

I am using Xojo in Mac OS X and I have a usb to serial device connect to it. How can I generate a list of my usb to serial port, so in the program I can choose one to open?

In Mac, I know to open a serial port using following code

Serial1.SerialPort = System.SerialPort("/dev/tty.usbserial-XXXXXXXX" 

the /dev/tty.usbserial-XXXXXXXX is the serial number of the port. How can I get that number string? or further step, how can I get detail info like, PID/VID etc?

Normally you use methods in system module to query number of serial ports and pick one.
So first you show them in a list or popup so user can select one.

[quote=45833:@Christian Schmitz]Normally you use methods in system module to query number of serial ports and pick one.
So first you show them in a list or popup so user can select one.[/quote]
can you give an example? I can find some codes in Xcoder to call “IOKit” in Mac OS X, but I don’t know how to use them in Xojo

did you look in Xojo documentation?
http://documentation.xojo.com/index.php/System.SerialPort

Yep, Thanks. It’s only solve a part of my problem. I still can’t have the PID/VID info or Vendor Name, for example, FTDI R232 UART, or similar. The “.Name” property only give out such as “usbserial-XXXXXX” info. It’s not enough if I have multiple devices, for example, I don’t want my bluetooth stuff shown in the list…

If I am not wrong, the serial class will not have that kind of information because that’s USB-related information.

I don’t know if you also get a USB device detected to query the system about (and I can’t check it right now).

Julen

[quote=45850:@Julen Ibarretxe Uriguen]If I am not wrong, the serial class will not have that kind of information because that’s USB-related information.

I don’t know if you also get a USB device detected to query the system about (and I can’t check it right now).

Julen[/quote]
yes, you are right, technically speaking, those info is USB info. In windows platform, the usb-to-serial adapter will work as a virtual COM port. I am not expected to obtain such info just go thru serial port class. But how can I get a usb info, such as PID/VID, in Xojo? Any idea?

We have an USB plugin with tons of classes related to USB devices. You can of course enumerate them or talk to one.

plugin:
http://www.monkeybreadsoftware.de/realbasic/plugin-usb.shtml

documentation:
http://www.monkeybreadsoftware.net/plugins-mbsusbplugin.shtml

and the MacUSBDeviceMBS class:
http://www.monkeybreadsoftware.net/class-macusbdevicembs.shtml

Just out of curiosity I ran Christian’s example (MBS)…

IORegistry Serial Devices.rbp

for plugin…

IORegistryNohttp://www.monkeybreadsoftware.net/plugins-mbsmacosxcfplugin.shtml

which, for me, shows a node called IOSerialBSDClient which shows you the modem name, with a sub-key down the chain calledIOUSBInterface which gives you the Vendor and Product IDs.

So you can use that information to link the device name to the device.

This is, of course, a specific case just on the hardware I have here, but I thought I’d share the information.

Using MBS’s plugins in a good option, but you should be able to query the OS directly. I can’t help you with that for OSX, but you might find the code you require in the MacOSLib (a free compilation of MacOS only functions).

Julen

I know this is an old thread, but I just came across it while looking up something else. A very useful command line function on the Mac OS is system_profile. It produces thousand of lines of detailed information, including all the USB/serial devices and drivers. You can use it from XOJO by executing it from the shell.

I have a small XOJO program installed on every Mac in our two companies. It periodically runs the system_profiler command, parses the information I want to save, saves the data to multiple SQLite tables, and performs several analysis of the data. I can see the Mac model type, OS and applications software versions, drivers, when every software update was performed, even battery charge levels for the laptops. As an IT Director, it is very valuable. The system_profiler command is recommended if you need to drill down into the details of your Mac hardware and software.

Simplified example. Place the following code in the Action event of a button on a page with a TextArea called TextArea1:

  //
  // Execute a Shell command to gather the system_profile information
  // Store the output to a TextArea in the window
  //
  
  dim sh as new shell
  dim theCommand as string
  
  theCommand = "system_profiler"
  sh.Execute(theCommand)    // this can take a long time, so be patient...
  
  If sh.ErrorCode=0 Then
    TextArea1.text = sh.Result
  Else
    TextArea1.Text = "Error " + Str(sh.ErrorCode)
  End If