Page 1 of 1

Re: OSX, PB & USB-RS232 serial ports

Posted: Fri Sep 17, 2010 7:37 pm
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.

Re: OSX, PB & USB-RS232 serial ports

Posted: Fri Oct 08, 2010 4:45 pm
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

Re: OSX, PB & USB-RS232 serial ports

Posted: Fri Oct 08, 2010 7:16 pm
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.