2013年4月14日 星期日

DIY - 智能小車:ser2net 詳細介紹 (二十一)

DIY - 智能小車:ser2net 詳細介紹 (二十一)

智能小車的無線路由器收發資料需要傳送到 16F877A 作處理,而兩者的連接是利用串行口 Serial Port)來實現,無線路由器的 OperWRT 也安裝了一個 ser2net 程式,ser2netSerial to network proxy)是為用戶提供了一個網絡到串口的進程,從網絡指定的 TCP 端口連接到串行端口,一旦連接發生,用戶便可以利用網絡收發資料,ser2net 是基於 GNU General Public License version 2.0 GPLv2 許可協議發行


程式句法:
ser2net [-c configfile] [-C configline] [-p controlport] [-n] [-d] [-b] [-v] [-P pidfile]
Options
Description
-c config-file           
Set the configuration file to one other than the default of /etc/ser2net.conf
-C config-line
Handle a single configuration line. This may be specified multiple times for multiple lines. This is just like a line in the config file. This disables the default config file, you must specify a -c after the last -C to have it read a config file, too.
-n
Stops the daemon from forking and detaching from the controlling terminal. This is useful for running from init.
-d
Like -n, but also sends the system logs to standard output. This is most useful for debugging purposes.
-P pidfile
If specified, put the process id (pid) of ser2net in the pidfile, replacing whatever was in that file previously. A pidfile is not created by default, you must specify this to create one. Note also that this filename must be specific with the full path, as ser2net will change directory to "/" when it becomes a daemon. when it
-u
If UUCP locking is enabled, this will disable the use of UUCP locks.
-b
Cisco IOS uses a different mechanism for specifying the baud rates than the mechanism described in RFC2217. This option sets the IOS version of setting the baud rates. The default is RFC2217's.
-v
Prints the version of the program and exits.
-p controlport
Enables the control port and sets the TCP port to listen to for the control port. A port number may be of the form [host,]port, such as 127.0.0.1,2000 or localhost,2000. If this is specified, it will only bind to the IP address specified for the port. Otherwise, it will bind to all the addresses on the machine.

If the port number is zero, that means that standard in/out will be used for the only input/output, and only one port should be specified in the config. This way, it can be used from inetd.

控制端口Control Port
控制端口提供一個簡單的控制端口和查看端口的狀態,控制端口有以下命令:
Control Port
Description
showport []
Show information about a port. If no port is given, all ports are displayed.
showshortport []
Show information about a port, each port on one line. If no port is given, all ports are displayed. This can produce very wide output.
help
Display a short list and summary of commands.
exit
Disconnect from the control port.
version
Display the version of this program.
monitor
Display all the input for a given port on the calling control port. Only one direction may be monitored at a time. The type field may be tcp or term and specifies whether to monitor data from the TCP port or from the serial port Note that data monitoring is best effort, if the controller port cannot keep up the data will be silently dropped. A controller may only monitor one thing and a port may only be monitored by one controller.
monitor stop
Stop the current monitor.
disconnect
Disconnect the tcp connection on the port.
setporttimeout
Set the amount of time in seconds before the port connection will be shut down if no activity has been seen on the port.
setportconfig
Set the port configuration as in the device configuration in the /etc/ser2net.conf file. If conflicting options are specified, the last option will be the one used. Note that these will not change until the port is disconnected and connected again. Options 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 set the various baud rates. EVEN, ODD, NONE set the parity. 1STOPBIT, 2STOPBITS set the number of stop bits. 7DATABITS, 8DATABITS set the number of data bits. [-]XONXOFF turns on (- off) XON/XOFF support. [-]RTSCTS turns on (- off) hardware flow control. [-]LOCAL ignores (- checks) the modem control lines (DCD, DTR, etc.)
setportcontrol
Modify dynamic port controls. These do not stay between connections. Controls are: DTRHI, DTRLO Turns on and off the DTR line. RTSHI, RTSLO Turns on and off the RTS line.
setportenable
Sets the port operation state. Valid states are: off to shut the TCP port down, raw to enable the TCP port transfer all I/O as-is, rawlp to enable the TCP port input and device output without termios setting, and telnet to enable the TCP port is up run the telnet negotiation protocol on the port.

配置(Configuration):
Ser2net通過文件/ etc/ser2net.conf配置,文件包含一個或多個項目及格式:
:::: 
BANNER::
TRACEFILE::
Fields
Description
TCP port
Name or number of the TCP/IP port to accept connections from for this device. A port number may be of the form [host,]port, such as 127.0.0.1,2000 or localhost,2000. If this is specified, it will only bind to the IP address specified for the port. Otherwise, it will bind to all the ports on the machine.
state
Either raw or rawlp or telnet or off. off disables the port from accepting connections. It can be turned on later from the control port. raw enables the port and transfers all data as-is between the port and the long. rawlp enables the port and transfers all input data to device, device is open without any termios setting. It allow to use /dev/lpX devices and printers connected to them. telnet enables the port and runs the telnet protocol on the port to set up telnet parameters. This is most useful for using telnet.
timeout
The time (in seconds) before the port will be disconnected if there is no activity on it. A zero value disables this funciton.
device
The name of the device to connect to. This must be in the form of /dev/.
device configuration options
Sets operational parameters for the serial port. Values may be separated by spaces or commas. Options 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 set the various baud rates. EVEN, ODD, NONE set the parity. 1STOPBIT, 2STOPBITS set the number of stop bits. 7DATABITS, 8DATABITS set the number of data bits. [-]XONXOFF turns on (- off) XON/XOFF support. [-]RTSCTS turns on (- off) hardware flow control. [-]LOCAL ignores (- checks) the modem control lines (DCD, DTR, etc.) [-]HANGUP_WHEN_DONE lowers (- does not lower) the modem control lines (DCD, DTR, etc.) when the connection closes. NOBREAK Disables automatic clearing of the break setting of the port. remctl allows remote control of the serial port parameters via RFC 2217. See the README for more info. displays the given banner when a user connects to the port.

tr= When the port is opened, open the given tracefile and store all data read from the physical device (and thus written to the user's TCP port) in the file. The actual filename is specified in the TRACEFILE directive. If the file already exists, it is appended. The file is closed when the port is closed.

tw= Like tr, but traces data written to the device.

tb= trace both read and written data to the same file. Note that this is independent of tr and tw, so you may be tracing read, write, and both to different files.
banner name
A name for the banner; this may be used in the options of a port.
banner text
The text to display as the banner. It takes escape sequences for substituting strings, see "FILENAME AND BANNER FORMATTING" for details.
tracefile name
A name for the tracefile, this is used in the tw, tr, and tb options of a port.
tracefile
The file to send the trace into. Note that this takes escape sequences for substituting strings, see "FILENAME AND BANNER FORMATTING" for details. Note that when using the time escape sequences, the time is read once at port startup, so if you use both tw and tr they will have the same date and time.
Blank lines and lines starting with '#' are ignored.

Filename Banner 格式Filename and Banner Formatting):
Filenames and banners may contain normal "C" escape sequences
A filename may also contain the following sequences:
\a - bell
\Y -> year
\b - backspace
\y -> day of the year (days since Jan 1)
\f - form feed
\M -> month (Jan, Feb, Mar, etc.)
\n - newline
\m -> month (as a number)
\r - carraige return
\A -> day of the week (Mon, Tue, etc.)
\t - tab
\D -> day of the month
\v - vertical tab
\e -> epoc (seconds since Jan 1, 1970)
\\ - \
\U -> microseconds in the current second
\? - ?
\p -> local port number
\' - '
\d -> local device name
\" - "
\I -> remote IP address (in dot format)
\nnn - octal value for nnn
\H -> hour (24-hour time)
\xXX - hex value for XX
\h -> hour (12-hour time)

\i -> minute

\s -> second

\q -> am/pm

\P -> AM/PM

相關網頁:
◎ DIY - 智能小車:TL-WR703N 無線路由器與 16F877A 控制版串口連接電路 (二十)
◎ DIY - 智能小車:ser2net 詳細介紹 (二十一)
◎ DIY - 智能小車:智能小車 ser2net 設定 (二十二)
◎ DIY - 智能小車:16F877A 控制版串口連接程式 (二十三)
◎ DIY - 智能小車:TL-WR703N 路由器和 RS232 串行板組裝 (二十九)
◎ DIY - 智能小車:PIC 16F877A 處理器板 RS232 接收程式碼 (三十三)
 


相關網頁:
 DIY - 電子:EIA RS-232 串行通信協議標準 (九十二) :
DIY - 電子:MAX232 串行通信協議標準 IC (九十三) :
 DIY - 電子:C18 PIC18F4550 USART 函數庫程式 (九十四) :
DIY - 電子:PIC18F4550 USART 電路功能介紹 (九十五) :
 DIY - 電子:PIC18F4550 USART 自動波特率電路介紹 (九十六) :
DIY - 電子:PIC18F4550 USART 異步模式 (九十七) :
◆ DIY - 電子:PIC18F4550 + MAX232 USART 電路 (九十八) :
◆ DIY - 電子:PIC18F4550 + MAX232 USART 電路程式 (九十九) :
DIY - 電子:PIC18F4550 測試程式 Hyper Terminal (一百) :

相關網頁:
◎ RS-232 ﹣串列數據通訊的介面標準 (一)
◎ RS-232 ﹣超級終端機串列介面測試 (二)
◎ RS-232 ﹣超級終端機串列介面 Loopback 測試 (三)
◎ RS-232 ﹣用 Excel 做串列介面數據傳輸及接收 (四)
◎ RS-232 ﹣用 Excel API做串列介面數據傳輸及接收 (五)

相關網頁:
◎ ESCORT 3146A 5 1/2位數字雙顯示桌上型電錶數據傳輸
◎ Hameg HM507 CombiScope (模數組合示波器) – RS232


2013 年 4月 14日 天氣報告
氣溫:19.6@ 22:10
相對濕度:百分之 75%
天氣:煙霞

沒有留言:

張貼留言