<doc>
	<legacy_id>2267</legacy_id>
	<name>open driver</name>
	<type>command</type>

	<syntax>
		<example>open driver <i>driverName</i> [for [[<i>encoding</i>] text | binary] {update | read | write}]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Establishes a connection to a <glossary tag="peripheral device">device</glossary> so you can send data to it or get data from it.</summary>

	<examples>
<example>open driver "/dev/cu.modem" for binary write</example>
<example>open driver (line 3 of it) for text read</example>
<example><p>open driver "COM2:" </p></example>
	</examples>

	<history>
		<introduced version="1.1.1">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		<changed version="7.0">7.0</changed>
<changed version="2.0">2.0</changed>
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
	</classes>

	<security>
		<disk/>
	</security>


	<classification>
		<category>Networks &amp; Communication</category>
	</classification>

	<references>
		<command tag="write to driver">write to driver Command</command>
		<property tag="recordInput">recordInput Property</property>
	</references>

	<description>Use the <b>open driver</b> <glossary tag="command">command</glossary> to communicate with USB <glossary tag="peripheral device">devices</glossary>, <glossary tag="peripheral device">devices</glossary> attached to a serial port other than the modem and printer port, and other <glossary tag="peripheral device">peripheral devices</glossary>.<p></p><p><b>Parameters:</b></p><p>The <i>driverName</i> specifies the name of a <glossary tag="device driver">device driver</glossary> that's installed on the system.</p><p></p><p><b>Comments:</b></p><p>If you don't specifyormode, the driver is opened in text mode. (For most devices, you should use binary mode.)</p><p></p><p>Use theform to open the driver for reading. If the driver is opened for reading, you can use the <b>read from driver</b> <glossary tag="command">command</glossary> to get data from the <glossary tag="peripheral device">device</glossary>, but you can't send data to it.</p><p></p><p>Use theorm to open the driver for writing. If the driver is opened for writing, you can use the <b>write to driver</b> <glossary tag="command">command</glossary> to send data to the <glossary tag="peripheral device">device</glossary> but you can't read from it.</p><p></p><p>Use theform to open the driver for both reading and writing. If the driver is opened for update, you can use both the <b>read from driver</b> and <command tag="write to driver">write to driver</command> <glossary tag="command">commands</glossary> to send data to the <glossary tag="peripheral device">device</glossary> or get data from it.</p><p></p><p>If the driver does not exist, the <b>result</b> <control_st tag="function">function</control_st> is set to "Can't open that file." On <glossary tag="OS X">OS X</glossary> and <glossary tag="Unix">Unix systems</glossary>, you can obtain a list of available <glossary tag="peripheral device">devices</glossary> by reading the file "/dev/tty".</p><p></p><p></p><p></p><p></p><p></p><note>On <glossary tag="Unix">Unix systems</glossary>, <glossary tag="peripheral device">devices</glossary> can be addressed as part of the file system. This means that on such systems, the following two <glossary tag="statement">statements</glossary> are equivalent:</note><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><tip>Because <glossary tag="OS X">OS X</glossary> is based on <glossary tag="Unix">Unix</glossary>, you can use the <command tag="open file">open file</command> <glossary tag="command">command</glossary>, as mentioned above, as a replacement for <b>open driver</b> on <glossary tag="OS X">OS X systems</glossary>.</tip><p></p><p>On Windows systems, the <b>open driver</b> <glossary tag="command">command</glossary> is equivalent to the <command tag="open file">open file</command> <glossary tag="command">command</glossary> when the <i>driverName</i> is <keyword tag="COMn:">COM1:</keyword>, <keyword tag="COMn:">COM2:</keyword>, etc.</p><p></p><p>If the device is a serial port, you can set the <b>serialControlString</b> <glossary tag="property">property</glossary> to specify the speed, parity, and other settings. Set the <property tag="serialControlString">serialControlString</property> before using the <b>open driver</b> <glossary tag="command">command</glossary>.</p><p></p><p></p><p></p><p></p><p></p><change><p>Support for using serial drivers with OS X systems was added in version 2.0.</change><p></p><p></p><p></p><p></p><change></change>The possibility of choosing an encoding when opening a process for a text operation was added in 7.0. It follows the encodings available in the functions <function tag="textEncode">textEncode</function> and <function tag="textDecode">textDecode</function>.</description>
</doc>