OSX, PB & USB-RS232 serial ports: SOLVED

Mac OSX specific forum
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: OSX, PB & USB-RS232 serial ports

Post by dhouston »

I've had a chance to test this and...

Code: Select all

If ExamineDirectory(0,"/dev/","tty.u*")
  While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_File
      MessageRequester("/dev/filename", DirectoryEntryName(0))
    EndIf
  Wend
  FinishDirectory(0)
EndIf
finds the three USB-Serial adapters I have connected. I will be modifying my Linux procedure accordingly as this is much simpler.
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: OSX, PB & USB-RS232 serial ports

Post by dhouston »

The code snippet below finds all the serial ports on my Intel mini but fails on my PPC iMac. I suspect I need to search a different directory(?) and/or use different search patterns. So far, I haven't figured out how to find, let alone view the contents, of /dev.

Code: Select all

  OpenPreferences(AppPath+"user.prf"):PreferenceGroup("user")
    ports = ReadPreferenceString("ports","NONE")    
    dirs = ReadPreferenceString("dirs","")    ; dirs = /dev
    patterns = ReadPreferenceString("patterns","")   ;patterns = tty.u*
  ClosePreferences()
  If ports="NONE"
    ports=""
    Protected i,j,dir.s,pattern.s
    NewList Comports.s()
    For i=1 To CountString(dirs,",")+1
      dir=StringField(dirs,i,",")
      For j=1 To CountString(patterns,",")+1
        pattern=StringField(patterns,j,",")
        If ExamineDirectory(0,dir,pattern)
          ;MessageRequester(dir,pattern)
          While NextDirectoryEntry(0)
            If DirectoryEntryType(0) = #PB_DirectoryEntry_File
              AddElement(ComPorts())
              ComPorts()=dir+"/"+DirectoryEntryName(0)              
            EndIf
          Wend
          FinishDirectory(0)
        EndIf  
      Next j
    Next i  
    SortList(ComPorts(),0)
    ForEach ComPorts()
      If FindString(ports,ComPorts(),1)=0               ;avoid duplicates
        If Len(ports):ports+",":EndIf
        ports+ComPorts()
      EndIf
    Next    
    ;MessageRequester("ports",ports)
  EndIf
EndProcedure
http://davehouston.org
Mac Mini (Intel) 10.6.8 - iMac G4 (PPC) 10.4.11
Dell Dimension 2400 W98SE,W2K,XP,Vista,W7,Debian,Ubuntu,Kubuntu,Xubuntu,Fedora,Mandriva,Mint
(on swappable HDDs)
Vizio VTAB1008 - Android 3.1
MK808 miniAndroidPC (Android 4.1)
User avatar
dhouston
Enthusiast
Enthusiast
Posts: 430
Joined: Tue Aug 21, 2007 2:44 pm
Location: USA (Cincinnati)
Contact:

Re: OSX, PB & USB-RS232 serial ports

Post by dhouston »

I had overlooked the need for drivers. Both of my test serial-USB adapters (one FTDI based, one Prolific based) showed up in System Profiler but I guess it took the installation of the drivers to actually create the /dev entries.
http://davehouston.org
Mac Mini (Intel) 10.6.8 - iMac G4 (PPC) 10.4.11
Dell Dimension 2400 W98SE,W2K,XP,Vista,W7,Debian,Ubuntu,Kubuntu,Xubuntu,Fedora,Mandriva,Mint
(on swappable HDDs)
Vizio VTAB1008 - Android 3.1
MK808 miniAndroidPC (Android 4.1)
Post Reply