วันนี้มีเคล็ดลับสำหรับท่านที่ใช้ ubuntu linux และต้องการ remote เข้าไปที่
อุปกรณ์ต่างๆเช่น router เพื่อทำการ config ค่าต่างที่ต้องการ
ในตัวอย่างนี้ผมมี usb port แปลงเป็น serial port 1 ตัว
ซึ่งพอเสียบ usb แล้ว มันจะ detect เจอเป็น /dev/ttyUSB0 โดย default
และต้องเช็ค log ก่อนว่า linux มันกำหนดให้เป็น device อะไร
$tail -f /var/log/messegs
May 5 09:07:53 ubuntu kernel: [46728.348000] usb 4-1: new full speed USB device using uhci_hcd and address 2
May 5 09:07:53 ubuntu kernel: [46728.500000] usb 4-1: configuration #1 chosen from 1 choice
May 5 09:07:53 ubuntu kernel: [46728.612000] usbcore: registered new interface driver usbserial
May 5 09:07:53 ubuntu kernel: [46728.612000] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
May 5 09:07:53 ubuntu kernel: [46728.616000] usbcore: registered new interface driver usbserial_generic
May 5 09:07:53 ubuntu kernel: [46728.616000] drivers/usb/serial/usb-serial.c: USB Serial Driver core
May 5 09:07:53 ubuntu kernel: [46728.684000] drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
May 5 09:07:53 ubuntu kernel: [46728.684000] pl2303 4-1:1.0: pl2303 converter detected
May 5 09:07:53 ubuntu kernel: [46728.688000] usb 4-1: pl2303 converter now attached to ttyUSB0
May 5 09:07:53 ubuntu kernel: [46728.688000] usbcore: registered new interface driver pl2303
May 5 09:07:53 ubuntu kernel: [46728.688000] drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver
จากตัวอย่างนี้ linux กำหนดให้เป็น ttyUSB0
จากนั้น เรียกโปรแกรม minicom ขึ้นมา config ค่าก่อนใช้งาน
$minicom -s
ให้เลือกไปที่ Serial port setup ก่อน
เลือก A แล้วกำหนด device เป็น /dev/ttyUSB0
เลือก E แล้วกำหนดเป็น 9600 8N1
เลือก F hardware flow control เลือกเป็น No
แล้วออกไปที่ menu หลัก
จากนั้นให้เลือก Save setup as dfl และ Exit from minicom ตามลำดับ
เป้นอัน เสร็จสิ้นขั้นตอนการ config minicom
ให้ทำการทดสอบดูว่า สามารถ connect ไปยังอุปกรณ์ router ได้หรือเปล่า
$minicom
หมายเหตุ
บน Ubuntu user สามารถใช้ได้งานเลย
บน RHEL ต้องใช้งานด้วย root account และก่อนใช้งานต้อง export TERMINAL environment ก่อนทุกครั้ง
#export TERM=vt100
อุปกรณ์ต่างๆเช่น router เพื่อทำการ config ค่าต่างที่ต้องการ
ในตัวอย่างนี้ผมมี usb port แปลงเป็น serial port 1 ตัว
ซึ่งพอเสียบ usb แล้ว มันจะ detect เจอเป็น /dev/ttyUSB0 โดย default
และต้องเช็ค log ก่อนว่า linux มันกำหนดให้เป็น device อะไร
$tail -f /var/log/messegs
May 5 09:07:53 ubuntu kernel: [46728.348000] usb 4-1: new full speed USB device using uhci_hcd and address 2
May 5 09:07:53 ubuntu kernel: [46728.500000] usb 4-1: configuration #1 chosen from 1 choice
May 5 09:07:53 ubuntu kernel: [46728.612000] usbcore: registered new interface driver usbserial
May 5 09:07:53 ubuntu kernel: [46728.612000] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic
May 5 09:07:53 ubuntu kernel: [46728.616000] usbcore: registered new interface driver usbserial_generic
May 5 09:07:53 ubuntu kernel: [46728.616000] drivers/usb/serial/usb-serial.c: USB Serial Driver core
May 5 09:07:53 ubuntu kernel: [46728.684000] drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
May 5 09:07:53 ubuntu kernel: [46728.684000] pl2303 4-1:1.0: pl2303 converter detected
May 5 09:07:53 ubuntu kernel: [46728.688000] usb 4-1: pl2303 converter now attached to ttyUSB0
May 5 09:07:53 ubuntu kernel: [46728.688000] usbcore: registered new interface driver pl2303
May 5 09:07:53 ubuntu kernel: [46728.688000] drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver
จากตัวอย่างนี้ linux กำหนดให้เป็น ttyUSB0
จากนั้น เรียกโปรแกรม minicom ขึ้นมา config ค่าก่อนใช้งาน
$minicom -s
ให้เลือกไปที่ Serial port setup ก่อน
เลือก A แล้วกำหนด device เป็น /dev/ttyUSB0
เลือก E แล้วกำหนดเป็น 9600 8N1
เลือก F hardware flow control เลือกเป็น No
แล้วออกไปที่ menu หลัก
จากนั้นให้เลือก Save setup as dfl และ Exit from minicom ตามลำดับ
เป้นอัน เสร็จสิ้นขั้นตอนการ config minicom
ให้ทำการทดสอบดูว่า สามารถ connect ไปยังอุปกรณ์ router ได้หรือเปล่า
$minicom
หมายเหตุ
บน Ubuntu user สามารถใช้ได้งานเลย
บน RHEL ต้องใช้งานด้วย root account และก่อนใช้งานต้อง export TERMINAL environment ก่อนทุกครั้ง
#export TERM=vt100