Name: open driver

Type: command

Syntax: open driver <driverName> [for [{[<encoding>] text | binary}] {update | read | write}]

Summary:
Establishes a connection to a <peripheral device|device> so you can send
data to it or get data from it.

Introduced: 1.1.1

OS: mac, windows, linux

Platforms: desktop, server

Security: disk

Example:
open driver "/dev/cu.modem" for binary write

Example:
open driver (line 3 of it) for text read

Example:
open driver "COM2:"

Parameters:
driverName:
The driverName specifies the name of a device driver that's installed on
the system.

encoding (enum):
The encoding to be used.

- "ASCII"
- "UTF-16"
- "UTF-16BE"
- "UTF-16LE"
- "UTF-32"
- "UTF-32BE"
- "UTF-32LE"
- "UTF-8"
- "CP1252"
- "ISO-8859-1": Linux only
- "MacRoman": OS X only
- "Native": ISO-8859-1 on Linux, MacRoman on OS X, CP1252 on Windows


The result:
If the driver does not exist, the result <function> is set to
"Can't open that file." On <OS X> and <Unix|Unix systems>, you can
obtain a list of available <peripheral device|devices> by reading the
file "/dev/tty".

Description:
Use the <open driver> <command> to communicate with USB 
<peripheral device|devices>, <peripheral device|devices> 
attached to a serial port other than the modem and 
printer port, and other <peripheral device|peripheral devices>.

If you don't specifyormode, the driver is opened in text mode. (For most
devices, you should use binary mode.)

Use the *read* form to open the driver for reading. If the driver is opened for
reading, you can use the read from driver <command> to get data from the
<peripheral device|device>, but you can't send data to it.

Use the *write* form to open the driver for writing. If the driver is opened for
writing, you can use the <write to driver> <command> to send data to the
<peripheral device|device> but you can't read from it.

Use the *update* form to open the driver for both reading and writing. If the
driver is opened for update, you can use both the read from driver and
<write to driver> <command|commands> to send data to the <peripheral
device|device> or get data from it.

>*Note:* On <Unix|Unix systems>, <peripheral device|devices> can be
> addressed as part of the file system. This means that on such systems,
> the following two <statement|statements> are equivalent:

>*Tip:* Because <OS X> is based on <Unix>, you can use the <open file>
> <command>, as mentioned above, as a replacement for <open driver> on
> <OS X|OS X systems>.

On Windows systems, the <open driver> <command> is equivalent to the
<open file> <command> when the <driverName> is <COMn:|COM1:>, 
<COMn:|COM2:>, etc.

If the device is a serial port, you can set the serialControlString
<property> to specify the speed, parity, and other settings. Set the
<serialControlString> before using the <open driver> <command>.

Changes:
The <encoding> parameter was introduced in version 7.0

References: write to driver (command), open file (command),
function (control structure), property (glossary), Unix (glossary),
statement (glossary), command (glossary), peripheral device (glossary),
OS X (glossary), COMn: (keyword), serialControlString (property), 
recordInput (property)

Tags: networking

