Addressing Hardware - particularly usb port

Phil Davis revdev at pdslabs.net
Thu Feb 12 15:49:38 CST 2009


P.S. - Here's how I send a command to the device after the 
"myDeviceNames" function tells me which devices are available:

global gCurrentDevice

on mouseUp
   -- locate the device driver
   put myDeviceNames() into tDevice
   filter tDevice with "usbmodem*"
   if tDevice = empty then
      answer "Can't find device."
      exit to top
   end if
  
   if the number of lines in tDevice > 1 then
      answer "Multiple device drivers!" & cr & tDevice
      exit to top
   end if
  
   put (item 3 of tDevice) into gCurrentDevice
   open driver gCurrentDevice for update
   put the result into fld "result"
   write tMyCommand & cr to driver gCurrentDevice -- be sure the CR is 
there!
   put the result into fld "result"
end mouseUp



Phil Davis wrote:
> Hey Peter,
>
> Is your device listed in the output of this function? If so, try 
> opening it and writing a command to it.
>
>
> function myDeviceNames
>  # Handler courtesy of Ken Ray & Dar Scott
>
>  local theNames="", ioregOutput, skipLines, temp
>  local IOTTYDevice, IODialinDevice, IOCalloutDevice
>  set the hideConsoleWindows to true
>  put shell("ioreg -n IOSerialBSDClient") into ioregOutput
>  repeat forever
>    put lineOffset("IOSerialBSDCLient",ioregOutput) into skipLines
>    if skipLines is zero then return thenames
>    delete line 1 to skipLines of ioregOutput
>    -- Get all the data between the braces
>    put char(offset("{",ioregOutput)) to (offset("}",ioregOutput)) of 
> ioregOutput into temp
>    get matchText(temp,"\"IOTTYDevice\" = \"(.*?)\"",IOTTYDevice)
>    if it is not true then next repeat
>    get matchText(temp,"\"IODialinDevice\" = \"(.*?)\"",IODialinDevice)
>    if it is not true then next repeat
>    get matchText(temp,"\"IOCalloutDevice\" = \"(.*?)\"",IOCalloutDevice)
>    if it is not true then next repeat
>    put IOTTYDevice,IODialinDevice,IOCalloutDevice & lineFeed after 
> theNames
>  end repeat
> end myDeviceNames
>
>
> HTH -
> Phil Davis
>
>
>
> Peter Alcibiades wrote:
>> Thanks everyone!  Its Linux, the OS that is being used.
>>
>> Sarah's article is interesting, but my problem is that the device is 
>> USB. So a serial to USB adaptor won't do it - it will allow use of a 
>> serial
>> device on a usb port.  If anything what I'd need would go the other 
>> way -
>> allow use of a usb device on a serial port.
>>
>> One other suggestion is to make one of the usb ports into a virtual 
>> serial
>> port.  Yes, maybe.  Again, not something I've ever gone near, but will
>> probably try it before this is over!  Apparently you can map them...
>>   
>

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net




More information about the use-livecode mailing list