在虛擬機器下測試
1、 修改檔案/etc/inittab
編輯檔案inittab,增加tty:2345:respawn:/sbin/agetty ttyS0 9600 vt100的內容:
# vi /etc/inittab
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
tty:2345:respawn:/sbin/agetty ttyS0 9600 vt100
“tty”為改行ID,“2345”指改行的運行層級是2、3、4、5級;“respawn”是使命令退出後再執行一次,以便其他使用者能夠登入;“/sbin/agetty ttyS0 9600 vt100”表示具體的命令,即通過他來執行開啟串口/dev/ttyS0(COM1),後面是傳輸速率和終端模式
2、 修改/etc/securetty檔案
編輯檔案/etc/securetty,增加ttyS0的內容:
該檔案是允許root身份登入的tty裝置列表,這些裝置由/bin/login程式讀取,為了使使用者能以root身份通過串口登入,需要在該檔案中添加“ttyS0”,說明系統認為這裡的COM1是安全的;
# vi /etc/securetty
console
ttyS0
……
3、 修改/boot/grub/menu.lst檔案或者修改/etc/grub.conf檔案
修改/boot/grub/menu.lst 檔案,在檔案的kernel 對應行上添加 “console=ttyS0,9600 console=tty0“,要令它生效需要重啟系統
# vi /boot/grub/menu.lst
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet crashkernel=128M@16M console=ttyS0,9600 console=tty0
initrd /boot/initrd-2.6.18-164.el5.img
4.關閉兩台虛擬機器一台linxu,一台xp
分別在兩台虛擬機器上,添加串口裝置,並設定。 編輯第一台虛擬機器,添加一個Serial Port,選擇use named pipe,然後輸入管道名稱: //./pipe/com_1,然後下面選擇this end is the server.和the other end is an application,把Yield CPU on poll勾上就可以了。 第二台虛擬機器同上,尤其管道名稱要一樣,下面選擇this end is the client.其他一樣
5.安裝設定Named Pipe TCP Proxy軟體
在主機上安裝設定Named Pipe TCP Proxy 開啟Named Pipe TCP Proxy,選擇Edit→New,然後設定好named pipe名稱和連接埠號碼 pipe設定為: //./pipe/com_1(和vmare中名稱一樣) port設定為:2001(隨機) , 其它預設。
6.測試
在xp虛擬機器上用putty選擇com1串連,傳輸速率9600,串連成功,登入系統