diff options
| author | Glenn Morris | 2008-06-13 08:05:52 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-06-13 08:05:52 +0000 |
| commit | c73e02fa6fc53e7c6df8d31021c83d8887ada8cd (patch) | |
| tree | bdd600059850bacdc1bd24d283b2a106fe683d6c | |
| parent | 3f6f1d8e865e1e033dc88472270614b2db064a21 (diff) | |
| download | emacs-c73e02fa6fc53e7c6df8d31021c83d8887ada8cd.tar.gz emacs-c73e02fa6fc53e7c6df8d31021c83d8887ada8cd.zip | |
Daniel Engeler <engeler at gmail.com>
elisp.texi, internals.texi, processes.texi: Add documentation about
serial port access.
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 1 | ||||
| -rw-r--r-- | doc/lispref/internals.texi | 11 | ||||
| -rw-r--r-- | doc/lispref/processes.texi | 285 |
4 files changed, 259 insertions, 43 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index b9e5ebb0fc1..808a1fd82e0 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-06-13 Daniel Engeler <engeler@gmail.com> | ||
| 2 | |||
| 3 | * elisp.texi, internals.texi, processes.texi: Add documentation | ||
| 4 | about serial port access. | ||
| 5 | |||
| 1 | 2008-06-05 Miles Bader <miles@gnu.org> | 6 | 2008-06-05 Miles Bader <miles@gnu.org> |
| 2 | 7 | ||
| 3 | * display.texi (Displaying Faces): Update to reflect function | 8 | * display.texi (Displaying Faces): Update to reflect function |
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index b73dc13b71a..248ba2476f7 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -1195,6 +1195,7 @@ Processes | |||
| 1195 | * Low-Level Network:: Lower-level but more general function | 1195 | * Low-Level Network:: Lower-level but more general function |
| 1196 | to create connections and servers. | 1196 | to create connections and servers. |
| 1197 | * Misc Network:: Additional relevant functions for network connections. | 1197 | * Misc Network:: Additional relevant functions for network connections. |
| 1198 | * Serial Ports:: Communicating with serial ports. | ||
| 1198 | * Byte Packing:: Using bindat to pack and unpack binary data. | 1199 | * Byte Packing:: Using bindat to pack and unpack binary data. |
| 1199 | 1200 | ||
| 1200 | Receiving Output from Processes | 1201 | Receiving Output from Processes |
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index 79c961ba4b5..c977b2e549f 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi | |||
| @@ -1433,7 +1433,8 @@ A string, the name of the process. | |||
| 1433 | 1433 | ||
| 1434 | @item command | 1434 | @item command |
| 1435 | A list containing the command arguments that were used to start this | 1435 | A list containing the command arguments that were used to start this |
| 1436 | process. | 1436 | process. For a network or serial process, it is @code{nil} if the |
| 1437 | process is running or @code{t} if the process is stopped. | ||
| 1437 | 1438 | ||
| 1438 | @item filter | 1439 | @item filter |
| 1439 | A function used to accept output from the process instead of a buffer, | 1440 | A function used to accept output from the process instead of a buffer, |
| @@ -1449,8 +1450,9 @@ The associated buffer of the process. | |||
| 1449 | An integer, the operating system's process @acronym{ID}. | 1450 | An integer, the operating system's process @acronym{ID}. |
| 1450 | 1451 | ||
| 1451 | @item childp | 1452 | @item childp |
| 1453 | |||
| 1452 | A flag, non-@code{nil} if this is really a child process. | 1454 | A flag, non-@code{nil} if this is really a child process. |
| 1453 | It is @code{nil} for a network connection. | 1455 | It is @code{nil} for a network or serial connection. |
| 1454 | 1456 | ||
| 1455 | @item mark | 1457 | @item mark |
| 1456 | A marker indicating the position of the end of the last output from this | 1458 | A marker indicating the position of the end of the last output from this |
| @@ -1515,6 +1517,11 @@ Size of carryover in encoding. | |||
| 1515 | @item inherit_coding_system_flag | 1517 | @item inherit_coding_system_flag |
| 1516 | Flag to set @code{coding-system} of the process buffer from the | 1518 | Flag to set @code{coding-system} of the process buffer from the |
| 1517 | coding system used to decode process output. | 1519 | coding system used to decode process output. |
| 1520 | |||
| 1521 | @item type | ||
| 1522 | Symbol indicating the type of process: @code{real}, @code{network}, | ||
| 1523 | @code{serial} | ||
| 1524 | |||
| 1518 | @end table | 1525 | @end table |
| 1519 | 1526 | ||
| 1520 | @ignore | 1527 | @ignore |
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index b26c69741b0..b3455dc9414 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi | |||
| @@ -53,6 +53,7 @@ This function returns @code{t} if @var{object} is a process, | |||
| 53 | * Low-Level Network:: Lower-level but more general function | 53 | * Low-Level Network:: Lower-level but more general function |
| 54 | to create connections and servers. | 54 | to create connections and servers. |
| 55 | * Misc Network:: Additional relevant functions for network connections. | 55 | * Misc Network:: Additional relevant functions for network connections. |
| 56 | * Serial Ports:: Communicating with serial ports. | ||
| 56 | * Byte Packing:: Using bindat to pack and unpack binary data. | 57 | * Byte Packing:: Using bindat to pack and unpack binary data. |
| 57 | @end menu | 58 | @end menu |
| 58 | 59 | ||
| @@ -676,6 +677,49 @@ were given to the program. | |||
| 676 | @end smallexample | 677 | @end smallexample |
| 677 | @end defun | 678 | @end defun |
| 678 | 679 | ||
| 680 | @defun process-contact process &optional key | ||
| 681 | |||
| 682 | This function returns information about how a network or serial | ||
| 683 | process was set up. For a network process, when @var{key} is | ||
| 684 | @code{nil}, it returns @code{(@var{hostname} @var{service})} which | ||
| 685 | specifies what you connected to. For a serial process, when @var{key} | ||
| 686 | is @code{nil}, it returns @code{(@var{port} @var{speed})}. For an | ||
| 687 | ordinary child process, this function always returns @code{t}. | ||
| 688 | |||
| 689 | If @var{key} is @code{t}, the value is the complete status information | ||
| 690 | for the connection, server, or serial port; that is, the list of | ||
| 691 | keywords and values specified in @code{make-network-process} or | ||
| 692 | @code{make-serial-process}, except that some of the values represent | ||
| 693 | the current status instead of what you specified. | ||
| 694 | |||
| 695 | For a network process: | ||
| 696 | |||
| 697 | @table @code | ||
| 698 | @item :buffer | ||
| 699 | The associated value is the process buffer. | ||
| 700 | @item :filter | ||
| 701 | The associated value is the process filter function. | ||
| 702 | @item :sentinel | ||
| 703 | The associated value is the process sentinel function. | ||
| 704 | @item :remote | ||
| 705 | In a connection, the address in internal format of the remote peer. | ||
| 706 | @item :local | ||
| 707 | The local address, in internal format. | ||
| 708 | @item :service | ||
| 709 | In a server, if you specified @code{t} for @var{service}, | ||
| 710 | this value is the actual port number. | ||
| 711 | @end table | ||
| 712 | |||
| 713 | @code{:local} and @code{:remote} are included even if they were not | ||
| 714 | specified explicitly in @code{make-network-process}. | ||
| 715 | |||
| 716 | For a serial process, see @code{make-serial-process} and | ||
| 717 | @code{serial-process-configure} for a list of keys. | ||
| 718 | |||
| 719 | If @var{key} is a keyword, the function returns the value corresponding | ||
| 720 | to that keyword. | ||
| 721 | @end defun | ||
| 722 | |||
| 679 | @defun process-id process | 723 | @defun process-id process |
| 680 | This function returns the @acronym{PID} of @var{process}. This is an | 724 | This function returns the @acronym{PID} of @var{process}. This is an |
| 681 | integer that distinguishes the process @var{process} from all other | 725 | integer that distinguishes the process @var{process} from all other |
| @@ -742,6 +786,12 @@ For a network connection, @code{process-status} returns one of the symbols | |||
| 742 | closed the connection, or Emacs did @code{delete-process}. | 786 | closed the connection, or Emacs did @code{delete-process}. |
| 743 | @end defun | 787 | @end defun |
| 744 | 788 | ||
| 789 | @defun process-type process | ||
| 790 | This function returns the symbol @code{network} for a network | ||
| 791 | connection or server, @code{serial} for a serial port connection, or | ||
| 792 | @code{real} for a real subprocess. | ||
| 793 | @end defun | ||
| 794 | |||
| 745 | @defun process-exit-status process | 795 | @defun process-exit-status process |
| 746 | This function returns the exit status of @var{process} or the signal | 796 | This function returns the exit status of @var{process} or the signal |
| 747 | number that killed it. (Use the result of @code{process-status} to | 797 | number that killed it. (Use the result of @code{process-status} to |
| @@ -1593,11 +1643,14 @@ server process, or @code{:type 'datagram} to create a datagram | |||
| 1593 | connection. @xref{Low-Level Network}, for details. You can also use | 1643 | connection. @xref{Low-Level Network}, for details. You can also use |
| 1594 | the @code{open-network-stream} function described below. | 1644 | the @code{open-network-stream} function described below. |
| 1595 | 1645 | ||
| 1596 | You can distinguish process objects representing network connections | 1646 | To distinguish the different types of processes, the |
| 1597 | and servers from those representing subprocesses with the | 1647 | @code{process-type} function returns the symbol @code{network} for a |
| 1598 | @code{process-status} function. The possible status values for | 1648 | network connection or server, @code{serial} for a serial port |
| 1599 | network connections are @code{open}, @code{closed}, @code{connect}, | 1649 | connection, or @code{real} for a real subprocess. |
| 1600 | and @code{failed}. For a network server, the status is always | 1650 | |
| 1651 | The @code{process-status} function returns @code{open}, | ||
| 1652 | @code{closed}, @code{connect}, and @code{failed} for network | ||
| 1653 | connections. For a network server, the status is always | ||
| 1601 | @code{listen}. None of those values is possible for a real | 1654 | @code{listen}. None of those values is possible for a real |
| 1602 | subprocess. @xref{Process Information}. | 1655 | subprocess. @xref{Process Information}. |
| 1603 | 1656 | ||
| @@ -1631,42 +1684,6 @@ The arguments @var{host} and @var{service} specify where to connect to; | |||
| 1631 | a defined network service (a string) or a port number (an integer). | 1684 | a defined network service (a string) or a port number (an integer). |
| 1632 | @end defun | 1685 | @end defun |
| 1633 | 1686 | ||
| 1634 | @defun process-contact process &optional key | ||
| 1635 | This function returns information about how a network process was set | ||
| 1636 | up. For a connection, when @var{key} is @code{nil}, it returns | ||
| 1637 | @code{(@var{hostname} @var{service})} which specifies what you | ||
| 1638 | connected to. | ||
| 1639 | |||
| 1640 | If @var{key} is @code{t}, the value is the complete status information | ||
| 1641 | for the connection or server; that is, the list of keywords and values | ||
| 1642 | specified in @code{make-network-process}, except that some of the | ||
| 1643 | values represent the current status instead of what you specified: | ||
| 1644 | |||
| 1645 | @table @code | ||
| 1646 | @item :buffer | ||
| 1647 | The associated value is the process buffer. | ||
| 1648 | @item :filter | ||
| 1649 | The associated value is the process filter function. | ||
| 1650 | @item :sentinel | ||
| 1651 | The associated value is the process sentinel function. | ||
| 1652 | @item :remote | ||
| 1653 | In a connection, the address in internal format of the remote peer. | ||
| 1654 | @item :local | ||
| 1655 | The local address, in internal format. | ||
| 1656 | @item :service | ||
| 1657 | In a server, if you specified @code{t} for @var{service}, | ||
| 1658 | this value is the actual port number. | ||
| 1659 | @end table | ||
| 1660 | |||
| 1661 | @code{:local} and @code{:remote} are included even if they were not | ||
| 1662 | specified explicitly in @code{make-network-process}. | ||
| 1663 | |||
| 1664 | If @var{key} is a keyword, the function returns the value corresponding | ||
| 1665 | to that keyword. | ||
| 1666 | |||
| 1667 | For an ordinary child process, this function always returns @code{t}. | ||
| 1668 | @end defun | ||
| 1669 | |||
| 1670 | @node Network Servers | 1687 | @node Network Servers |
| 1671 | @section Network Servers | 1688 | @section Network Servers |
| 1672 | @cindex network servers | 1689 | @cindex network servers |
| @@ -2099,6 +2116,192 @@ If the vector does not include the port number, @var{p}, or if | |||
| 2099 | @code{:@var{p}} suffix. | 2116 | @code{:@var{p}} suffix. |
| 2100 | @end defun | 2117 | @end defun |
| 2101 | 2118 | ||
| 2119 | @node Serial Ports | ||
| 2120 | @section Communicating with Serial Ports | ||
| 2121 | @cindex @file{/dev/tty} | ||
| 2122 | @cindex @file{COM1} | ||
| 2123 | |||
| 2124 | Emacs can communicate with serial ports. For interactive use, | ||
| 2125 | @kbd{M-x serial-term} opens a terminal window. In a Lisp program, | ||
| 2126 | @code{make-serial-process} creates a process object. | ||
| 2127 | |||
| 2128 | The serial port can be configured at run-time, without having to | ||
| 2129 | close and re-open it. The function @code{serial-process-configure} | ||
| 2130 | lets you change the speed, bytesize, and other parameters. In a | ||
| 2131 | terminal window created by @code{serial-term}, you can click on the | ||
| 2132 | mode line for configuration. | ||
| 2133 | |||
| 2134 | A serial connection is represented by a process object which can be | ||
| 2135 | used similar to a subprocess or network process. You can send and | ||
| 2136 | receive data and configure the serial port. A serial process object | ||
| 2137 | has no process ID, and you can't send signals to it. | ||
| 2138 | @code{delete-process} on the process object or @code{kill-buffer} on | ||
| 2139 | the process buffer close the connection, but this does not affect the | ||
| 2140 | device connected to the serial port. | ||
| 2141 | |||
| 2142 | The function @code{process-type} returns the symbol @code{serial} | ||
| 2143 | for a process object representing a serial port. | ||
| 2144 | |||
| 2145 | Serial ports are available on GNU/Linux, Unix, and Windows systems. | ||
| 2146 | |||
| 2147 | @defun serial-term port speed | ||
| 2148 | Start a terminal-emulator for a serial port in a new buffer. | ||
| 2149 | @var{port} is the path or name of the serial port. For example, this | ||
| 2150 | could be @file{/dev/ttyS0} on Unix. On Windows, this could be | ||
| 2151 | @file{COM1}, or @file{\\.\COM10} (double the backslashes in strings). | ||
| 2152 | |||
| 2153 | @var{speed} is the speed of the serial port in bits per second. 9600 | ||
| 2154 | is a common value. The buffer is in Term mode; see @code{term-mode} | ||
| 2155 | for the commands to use in that buffer. You can change the speed and | ||
| 2156 | the configuration in the mode line menu. @end defun | ||
| 2157 | |||
| 2158 | @defun make-serial-process &rest args | ||
| 2159 | @code{make-serial-process} creates a process and a buffer. Arguments | ||
| 2160 | are specified as keyword/argument pairs. The following arguments are | ||
| 2161 | defined: | ||
| 2162 | |||
| 2163 | @table @code | ||
| 2164 | @item :port port | ||
| 2165 | @var{port} (mandatory) is the path or name of the serial port. | ||
| 2166 | For example, this could be @file{/dev/ttyS0} on Unix. On Windows, | ||
| 2167 | this could be @file{COM1}, or @file{\\.\COM10} for ports higher than | ||
| 2168 | @file{COM9} (double the backslashes in strings). | ||
| 2169 | |||
| 2170 | @item :speed speed | ||
| 2171 | @var{speed} (mandatory) is handled by @code{serial-process-configure}, | ||
| 2172 | which is called by @code{make-serial-process}. | ||
| 2173 | |||
| 2174 | @item :name name | ||
| 2175 | @var{name} is the name of the process. If @var{name} is not given, the | ||
| 2176 | value of @var{port} is used. | ||
| 2177 | |||
| 2178 | @item :buffer buffer | ||
| 2179 | @var{buffer} is the buffer (or buffer-name) to associate with the | ||
| 2180 | process. Process output goes at the end of that buffer, unless you | ||
| 2181 | specify an output stream or filter function to handle the output. If | ||
| 2182 | @var{buffer} is not given, the value of @var{name} is used. | ||
| 2183 | |||
| 2184 | @item :coding coding | ||
| 2185 | If @var{coding} is a symbol, it specifies the coding system used for | ||
| 2186 | both reading and writing for this process. If @var{coding} is a cons | ||
| 2187 | @code{(decoding . encoding)}, @var{decoding} is used for reading, and | ||
| 2188 | @var{encoding} is used for writing. | ||
| 2189 | |||
| 2190 | @item :noquery bool | ||
| 2191 | When exiting Emacs, query the user if @var{bool} is @code{nil} and the | ||
| 2192 | process is running. If @var{bool} is not given, query before exiting. | ||
| 2193 | |||
| 2194 | @item :stop bool | ||
| 2195 | Start process in the @code{stopped} state if @var{bool} is | ||
| 2196 | non-@code{nil}. In the stopped state, a serial process does not | ||
| 2197 | accept incoming data, but you can send outgoing data. The stopped | ||
| 2198 | state is cleared by @code{continue-process} and set by | ||
| 2199 | @code{stop-process}. | ||
| 2200 | |||
| 2201 | @item :filter filter | ||
| 2202 | Install @var{filter} as the process filter. | ||
| 2203 | |||
| 2204 | @item :sentinel sentinel | ||
| 2205 | Install @var{sentinel} as the process sentinel. | ||
| 2206 | |||
| 2207 | @item :plist plist | ||
| 2208 | Install @var{plist} as the initial plist of the process. | ||
| 2209 | |||
| 2210 | @item :speed | ||
| 2211 | @itemx :bytesize | ||
| 2212 | @itemx :parity | ||
| 2213 | @itemx :stopbits | ||
| 2214 | @itemx :flowcontrol | ||
| 2215 | These arguments are handled by @code{serial-process-configure}, which | ||
| 2216 | is called by @code{make-serial-process}. | ||
| 2217 | @end table | ||
| 2218 | |||
| 2219 | The original argument list, possibly modified by later configuration, | ||
| 2220 | is available via the function @code{process-contact}. | ||
| 2221 | |||
| 2222 | Examples: | ||
| 2223 | |||
| 2224 | @example | ||
| 2225 | (make-serial-process :port "/dev/ttyS0" :speed 9600) | ||
| 2226 | |||
| 2227 | (make-serial-process :port "COM1" :speed 115200 :stopbits 2) | ||
| 2228 | |||
| 2229 | (make-serial-process :port "\\\\.\\COM13" :speed 1200 :bytesize 7 :parity 'odd) | ||
| 2230 | |||
| 2231 | (make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil) | ||
| 2232 | @end example | ||
| 2233 | @end defun | ||
| 2234 | |||
| 2235 | @defun serial-process-configure &rest args | ||
| 2236 | @cindex baud | ||
| 2237 | @cindex bytesize | ||
| 2238 | @cindex parity | ||
| 2239 | @cindex stopbits | ||
| 2240 | @cindex flowcontrol | ||
| 2241 | |||
| 2242 | Configure a serial port. Arguments are specified as keyword/argument | ||
| 2243 | pairs. Attributes that are not given are re-initialized from the | ||
| 2244 | process's current configuration (available via the function | ||
| 2245 | @code{process-contact}) or set to reasonable default values. The | ||
| 2246 | following arguments are defined: | ||
| 2247 | |||
| 2248 | @table @code | ||
| 2249 | @item :process process | ||
| 2250 | @itemx :name name | ||
| 2251 | @itemx :buffer buffer | ||
| 2252 | @itemx :port port | ||
| 2253 | Any of these arguments can be given to identify the process that is to | ||
| 2254 | be configured. If none of these arguments is given, the current | ||
| 2255 | buffer's process is used. | ||
| 2256 | |||
| 2257 | @item :speed @var{speed} | ||
| 2258 | @var{speed} is the speed of the serial port in bits per second, also | ||
| 2259 | called baud rate. Any value can be given for @var{speed}, but most | ||
| 2260 | serial ports work only at a few defined values between 1200 and | ||
| 2261 | 115200, with 9600 being the most common value. If @var{speed} is | ||
| 2262 | @code{nil}, the serial port is not configured any further, i.e., all | ||
| 2263 | other arguments are ignored. This may be useful for special serial | ||
| 2264 | ports such as Bluetooth-to-serial converters which can only be | ||
| 2265 | configured through AT commands. A value of @code{nil} for @var{speed} | ||
| 2266 | can be used only when passed through @code{make-serial-process} or | ||
| 2267 | @code{serial-term}. | ||
| 2268 | |||
| 2269 | @item :bytesize @var{bytesize} | ||
| 2270 | @var{bytesize} is the number of bits per byte, which can be 7 or 8. | ||
| 2271 | If @var{bytesize} is not given or @code{nil}, a value of 8 is used. | ||
| 2272 | |||
| 2273 | @item :parity @var{parity} | ||
| 2274 | @var{parity} can be @code{nil} (don't use parity), the symbol | ||
| 2275 | @code{odd} (use odd parity), or the symbol @code{even} (use even | ||
| 2276 | parity). If @var{parity} is not given, no parity is used. | ||
| 2277 | |||
| 2278 | @item :stopbits @var{stopbits} | ||
| 2279 | @var{stopbits} is the number of stopbits used to terminate a byte | ||
| 2280 | transmission. @var{stopbits} can be 1 or 2. If @var{stopbits} is not | ||
| 2281 | given or @code{nil}, 1 stopbit is used. | ||
| 2282 | |||
| 2283 | @item :flowcontrol @var{flowcontrol} | ||
| 2284 | @var{flowcontrol} determines the type of flowcontrol to be used, which | ||
| 2285 | is either @code{nil} (don't use flowcontrol), the symbol @code{hw} | ||
| 2286 | (use RTS/CTS hardware flowcontrol), or the symbol @code{sw} (use | ||
| 2287 | XON/XOFF software flowcontrol). If @var{flowcontrol} is not given, no | ||
| 2288 | flowcontrol is used. | ||
| 2289 | @end table | ||
| 2290 | |||
| 2291 | @code{serial-process-configure} is called by @code{make-serial-process} for the | ||
| 2292 | initial configuration of the serial port. | ||
| 2293 | |||
| 2294 | Examples: | ||
| 2295 | |||
| 2296 | @example | ||
| 2297 | (serial-process-configure :process "/dev/ttyS0" :speed 1200) | ||
| 2298 | |||
| 2299 | (serial-process-configure :buffer "COM1" :stopbits 1 :parity 'odd :flowcontrol 'hw) | ||
| 2300 | |||
| 2301 | (serial-process-configure :port "\\\\.\\COM13" :bytesize 7) | ||
| 2302 | @end example | ||
| 2303 | @end defun | ||
| 2304 | |||
| 2102 | @node Byte Packing | 2305 | @node Byte Packing |
| 2103 | @section Packing and Unpacking Byte Arrays | 2306 | @section Packing and Unpacking Byte Arrays |
| 2104 | @cindex byte packing and unpacking | 2307 | @cindex byte packing and unpacking |