aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-06-13 08:05:52 +0000
committerGlenn Morris2008-06-13 08:05:52 +0000
commitc73e02fa6fc53e7c6df8d31021c83d8887ada8cd (patch)
treebdd600059850bacdc1bd24d283b2a106fe683d6c
parent3f6f1d8e865e1e033dc88472270614b2db064a21 (diff)
downloademacs-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/ChangeLog5
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/internals.texi11
-rw-r--r--doc/lispref/processes.texi285
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 @@
12008-06-13 Daniel Engeler <engeler@gmail.com>
2
3 * elisp.texi, internals.texi, processes.texi: Add documentation
4 about serial port access.
5
12008-06-05 Miles Bader <miles@gnu.org> 62008-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
1200Receiving Output from Processes 1201Receiving 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
1435A list containing the command arguments that were used to start this 1435A list containing the command arguments that were used to start this
1436process. 1436process. For a network or serial process, it is @code{nil} if the
1437process is running or @code{t} if the process is stopped.
1437 1438
1438@item filter 1439@item filter
1439A function used to accept output from the process instead of a buffer, 1440A function used to accept output from the process instead of a buffer,
@@ -1449,8 +1450,9 @@ The associated buffer of the process.
1449An integer, the operating system's process @acronym{ID}. 1450An integer, the operating system's process @acronym{ID}.
1450 1451
1451@item childp 1452@item childp
1453
1452A flag, non-@code{nil} if this is really a child process. 1454A flag, non-@code{nil} if this is really a child process.
1453It is @code{nil} for a network connection. 1455It is @code{nil} for a network or serial connection.
1454 1456
1455@item mark 1457@item mark
1456A marker indicating the position of the end of the last output from this 1458A 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
1516Flag to set @code{coding-system} of the process buffer from the 1518Flag to set @code{coding-system} of the process buffer from the
1517coding system used to decode process output. 1519coding system used to decode process output.
1520
1521@item type
1522Symbol 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
682This function returns information about how a network or serial
683process was set up. For a network process, when @var{key} is
684@code{nil}, it returns @code{(@var{hostname} @var{service})} which
685specifies what you connected to. For a serial process, when @var{key}
686is @code{nil}, it returns @code{(@var{port} @var{speed})}. For an
687ordinary child process, this function always returns @code{t}.
688
689If @var{key} is @code{t}, the value is the complete status information
690for the connection, server, or serial port; that is, the list of
691keywords and values specified in @code{make-network-process} or
692@code{make-serial-process}, except that some of the values represent
693the current status instead of what you specified.
694
695For a network process:
696
697@table @code
698@item :buffer
699The associated value is the process buffer.
700@item :filter
701The associated value is the process filter function.
702@item :sentinel
703The associated value is the process sentinel function.
704@item :remote
705In a connection, the address in internal format of the remote peer.
706@item :local
707The local address, in internal format.
708@item :service
709In a server, if you specified @code{t} for @var{service},
710this value is the actual port number.
711@end table
712
713@code{:local} and @code{:remote} are included even if they were not
714specified explicitly in @code{make-network-process}.
715
716For a serial process, see @code{make-serial-process} and
717@code{serial-process-configure} for a list of keys.
718
719If @var{key} is a keyword, the function returns the value corresponding
720to that keyword.
721@end defun
722
679@defun process-id process 723@defun process-id process
680This function returns the @acronym{PID} of @var{process}. This is an 724This function returns the @acronym{PID} of @var{process}. This is an
681integer that distinguishes the process @var{process} from all other 725integer 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
742closed the connection, or Emacs did @code{delete-process}. 786closed the connection, or Emacs did @code{delete-process}.
743@end defun 787@end defun
744 788
789@defun process-type process
790This function returns the symbol @code{network} for a network
791connection 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
746This function returns the exit status of @var{process} or the signal 796This function returns the exit status of @var{process} or the signal
747number that killed it. (Use the result of @code{process-status} to 797number 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
1593connection. @xref{Low-Level Network}, for details. You can also use 1643connection. @xref{Low-Level Network}, for details. You can also use
1594the @code{open-network-stream} function described below. 1644the @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
1597and 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 1648network connection or server, @code{serial} for a serial port
1599network connections are @code{open}, @code{closed}, @code{connect}, 1649connection, or @code{real} for a real subprocess.
1600and @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
1653connections. 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
1602subprocess. @xref{Process Information}. 1655subprocess. @xref{Process Information}.
1603 1656
@@ -1631,42 +1684,6 @@ The arguments @var{host} and @var{service} specify where to connect to;
1631a defined network service (a string) or a port number (an integer). 1684a 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
1635This function returns information about how a network process was set
1636up. For a connection, when @var{key} is @code{nil}, it returns
1637@code{(@var{hostname} @var{service})} which specifies what you
1638connected to.
1639
1640If @var{key} is @code{t}, the value is the complete status information
1641for the connection or server; that is, the list of keywords and values
1642specified in @code{make-network-process}, except that some of the
1643values represent the current status instead of what you specified:
1644
1645@table @code
1646@item :buffer
1647The associated value is the process buffer.
1648@item :filter
1649The associated value is the process filter function.
1650@item :sentinel
1651The associated value is the process sentinel function.
1652@item :remote
1653In a connection, the address in internal format of the remote peer.
1654@item :local
1655The local address, in internal format.
1656@item :service
1657In a server, if you specified @code{t} for @var{service},
1658this value is the actual port number.
1659@end table
1660
1661@code{:local} and @code{:remote} are included even if they were not
1662specified explicitly in @code{make-network-process}.
1663
1664If @var{key} is a keyword, the function returns the value corresponding
1665to that keyword.
1666
1667For 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
2129close and re-open it. The function @code{serial-process-configure}
2130lets you change the speed, bytesize, and other parameters. In a
2131terminal window created by @code{serial-term}, you can click on the
2132mode line for configuration.
2133
2134 A serial connection is represented by a process object which can be
2135used similar to a subprocess or network process. You can send and
2136receive data and configure the serial port. A serial process object
2137has no process ID, and you can't send signals to it.
2138@code{delete-process} on the process object or @code{kill-buffer} on
2139the process buffer close the connection, but this does not affect the
2140device connected to the serial port.
2141
2142 The function @code{process-type} returns the symbol @code{serial}
2143for 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
2148Start 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
2150could 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
2154is a common value. The buffer is in Term mode; see @code{term-mode}
2155for the commands to use in that buffer. You can change the speed and
2156the 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
2160are specified as keyword/argument pairs. The following arguments are
2161defined:
2162
2163@table @code
2164@item :port port
2165@var{port} (mandatory) is the path or name of the serial port.
2166For example, this could be @file{/dev/ttyS0} on Unix. On Windows,
2167this 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},
2172which 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
2176value of @var{port} is used.
2177
2178@item :buffer buffer
2179@var{buffer} is the buffer (or buffer-name) to associate with the
2180process. Process output goes at the end of that buffer, unless you
2181specify 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
2185If @var{coding} is a symbol, it specifies the coding system used for
2186both 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
2191When exiting Emacs, query the user if @var{bool} is @code{nil} and the
2192process is running. If @var{bool} is not given, query before exiting.
2193
2194@item :stop bool
2195Start process in the @code{stopped} state if @var{bool} is
2196non-@code{nil}. In the stopped state, a serial process does not
2197accept incoming data, but you can send outgoing data. The stopped
2198state is cleared by @code{continue-process} and set by
2199@code{stop-process}.
2200
2201@item :filter filter
2202Install @var{filter} as the process filter.
2203
2204@item :sentinel sentinel
2205Install @var{sentinel} as the process sentinel.
2206
2207@item :plist plist
2208Install @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
2215These arguments are handled by @code{serial-process-configure}, which
2216is called by @code{make-serial-process}.
2217@end table
2218
2219The original argument list, possibly modified by later configuration,
2220is available via the function @code{process-contact}.
2221
2222Examples:
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
2242Configure a serial port. Arguments are specified as keyword/argument
2243pairs. Attributes that are not given are re-initialized from the
2244process's current configuration (available via the function
2245@code{process-contact}) or set to reasonable default values. The
2246following arguments are defined:
2247
2248@table @code
2249@item :process process
2250@itemx :name name
2251@itemx :buffer buffer
2252@itemx :port port
2253Any of these arguments can be given to identify the process that is to
2254be configured. If none of these arguments is given, the current
2255buffer'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
2259called baud rate. Any value can be given for @var{speed}, but most
2260serial ports work only at a few defined values between 1200 and
2261115200, 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
2263other arguments are ignored. This may be useful for special serial
2264ports such as Bluetooth-to-serial converters which can only be
2265configured through AT commands. A value of @code{nil} for @var{speed}
2266can 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.
2271If @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
2276parity). 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
2280transmission. @var{stopbits} can be 1 or 2. If @var{stopbits} is not
2281given 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
2285is either @code{nil} (don't use flowcontrol), the symbol @code{hw}
2286(use RTS/CTS hardware flowcontrol), or the symbol @code{sw} (use
2287XON/XOFF software flowcontrol). If @var{flowcontrol} is not given, no
2288flowcontrol is used.
2289@end table
2290
2291@code{serial-process-configure} is called by @code{make-serial-process} for the
2292initial configuration of the serial port.
2293
2294Examples:
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