아래의 command를 순서대로 입력하여 ser2net application을 다운로드 한다.
jwsung@jwsung-ubuntu:~$ add-apt-repository ppa:eugenesan/ppa
jwsung@jwsung-ubuntu:~$ sudo apt-get update
jwsung@jwsung-ubuntu:~$ sudo apt-get install ser2net -y
시리얼 연결 케이블은 USB to RS232를 사용 하였다.
케이블을 연결하기 전과 연결 후 lsusb 명령으로 device ID를 확인한다.
jwsung@jwsung-ubuntu:~$ lsusb
Bus 001 Device 002: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 248a:8566
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
jwsung@jwsung-ubuntu:~$
jwsung@jwsung-ubuntu:~$ lsusb
Bus 001 Device 002: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 248a:8566
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
jwsung@jwsung-ubuntu:~$
device에 대한 상세한 정보는 아래 command로 확인 가능하다.
jwsung@jwsung-ubuntu:~$ lsusb -v -d 0403:6001
Bus 003 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6001 FT232 Serial (UART) IC
bcdDevice 6.00
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 44mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
jwsung@jwsung-ubuntu:~$
jwsung@jwsung-ubuntu:~$ sudo modprobe usbserial vendor=0x0403 product=0x6001
USB serial device의 이름을 확인한다.
jwsung@jwsung-ubuntu:~$ dmesg | tail -n 20
[ 4356.040341] r8169 0000:04:00.0 eth1: link down
[ 4360.004844] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[ 8333.972013] usb 3-2: new full-speed USB device number 2 using uhci_hcd
[ 8334.172050] usb 3-2: New USB device found, idVendor=0403, idProduct=6001
[ 8334.172054] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 8334.172057] usb 3-2: Product: USB Serial Converter
[ 8334.172060] usb 3-2: Manufacturer: FTDI
[ 8334.172062] usb 3-2: SerialNumber: FTFWAUT4
[ 8334.223674] usbcore: registered new interface driver usbserial
[ 8334.223684] usbcore: registered new interface driver usbserial_generic
[ 8334.223692] usbserial: USB Serial support registered for generic
[ 8334.263114] usbcore: registered new interface driver ftdi_sio
[ 8334.263128] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 8334.263193] ftdi_sio 3-2:1.0: FTDI USB Serial Device converter detected
[ 8334.263216] usb 3-2: Detected FT232RL
[ 8334.263218] usb 3-2: Number of endpoints 2
[ 8334.263219] usb 3-2: Endpoint 1 MaxPacketSize 64
[ 8334.263221] usb 3-2: Endpoint 2 MaxPacketSize 64
[ 8334.263223] usb 3-2: Setting MaxPacketSize 64
[ 8334.266087] usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB0
jwsung@jwsung-ubuntu:~$
따로 help string을 위한 option은 없는 거 같은데 그냥 -h 해도 나올만한건 다 나온다 -.-
jwsung@jwsung-ubuntu:~$ ser2net -h
Invalid option: '-h'
ser2net: Valid parameters are:
-c <config file> - use a config file besides /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.
-p <controller port> - Start a controller session on the given TCP port
-P <file> - set location of pid file
-n - Don't detach from the controlling terminal
-d - Don't detach and send debug I/O to standard output
-u - Disable UUCP locking
-b - Do CISCO IOS baud-rate negotiation, instead of RFC2217
-v - print the program's version and exit
-s - specify a default signature for RFC2217 protocol
jwsung@jwsung-ubuntu:~$
ser2net 프로그램 설치와 USB serial device 설정이 끝났으면 /etc/ser2net.conf 설정 파일을 연다.
jwsung@jwsung-ubuntu:~$ sudo vim /etc/ser2net.conf
파일을 열면 아래와 같이 2001 ~ 3001 port로 예제 비스무리한 것이 이미 들어가 있다. 파일에 각 항목에 대해 친절하게 설명 되어 있지만 대충 처음에서 부터
사용할 포트 : 사용할 프로토콜 : 세션 타임아웃 값 : 디바이스 : baud rate 순으로 이어 진다.
본인이 추가한 설정은 /dev/ttyUSB0 에 대해 텔넷으로 10001포트를 쓰며 session timeout은 0 (무한), baud rate는 115200 로 설정 하였다.
2000:telnet:600:/dev/ttyS0:9600 8DATABITS NONE 1STOPBIT banner
2001:telnet:600:/dev/ttyS1:9600 8DATABITS NONE 1STOPBIT banner
3000:telnet:600:/dev/ttyS0:19200 8DATABITS NONE 1STOPBIT banner
3001:telnet:600:/dev/ttyS1:19200 8DATABITS NONE 1STOPBIT banner
10001:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
아래와 같이 10000번 포트를 controller port로 지정 한다. 이후 10000번 port로 접속하면 baud rate나 각 session의 disconnect 등을 수행할 수 있게 된다.
jwsung@jwsung-ubuntu:~$ sudo ser2net -p 10000
원격지에서 PC IP의 10001 port로 telnet 접속을 하였을 때 serial 로 연결한 console 화면이 보이는 것을 볼 수 있다.
ser2net port 10001 device /dev/ttyUSB0 [115200 N81] (Debian GNU/Linux)
Login: admin
Password:
ser2net의 restart가 필요한 경우 아래 command를 수행 한다.
jwsung@jwsung-ubuntu:~$ sudo /etc/init.d/ser2net restart
* Restarting Serial port to network proxy ser2net [ OK ]
jwsung@jwsung-ubuntu:~$
참고 :