Talking to a GPS unit over USB
Dar Scott
dsc at swcp.com
Sat Apr 10 20:43:37 EDT 2004
On Saturday, April 10, 2004, at 05:51 PM, Trevor DeVore wrote:
>> I would expect that a GPS unit with a USB interface is set up to look
>> just like serial. If that is not the case, you will not be able to
>> establish communications without something special.
> Rats, it looks like it isn't going to work . driverNames() returns
> empty. There is a serial connection cable that I can get for it. I
> have a Keyspan serial->USB converter so I think I will pick that up
> and give it a try.
Rats. I am surprised; the GPS protocols are based on a family of
navigation standards that specifies serial.
Here is an alternative to driverNames() that might come up with a
different answer. (I only know of driverNames() missing the built-in
modem; if you see anything else in deviceNames() and not in
driverNames(), please let me know.)
-- Ken Ray and Dar Scott did this
function deviceNames
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 deviceNames
Another clue that you can open it as serial is finding it with 'ls
/dev/cu.*'.
I think there are three categories of serial devices in OS X and I
suspect that driverNames() only looks in one.
Dar Scott
More information about the use-livecode
mailing list