Minicom 狀態保持離線狀態

Minicom 狀態保持離線狀態

我已經透過以下命令安裝了minicom:

sudo apt-get minicom

我透過 USB 轉串列控制台連接線與 HP 5130 交換器連接。根據以下命令,我的串列埠名稱是/dev/ttyUSB0:

dmesg | grep tty
[    0.000000] console [tty0] enabled
[49689.082419] usb 3-2: pl2303 converter now attached to ttyUSB0

額外檢查:

ls -l /dev/ttyUSB0 

如果拔掉 USB 電纜,則會出現下列錯誤:

ls: cannot access /dev/ttyUSB0: No such file or directory

所以我認為 ttyUSB0 是正確的連接埠是正確的

我編輯了minicom的設定如下:

+-----------------------------------------------------------------------+   
| A -    Serial Device      : /dev/ttyUSB0                              |   
| B - Lockfile Location     : /var/lock                                 |   
| C -   Callin Program      :                                           |   
| D -  Callout Program      :                                           |   
| E -    Bps/Par/Bits       : 9600 8N1                                  |   
| F - Hardware Flow Control : Yes                                       |   
| G - Software Flow Control : No                                        |   
|                                                                       |   
|    Change which setting?                                              |   
+-----------------------------------------------------------------------+   

並啟動了 minicom

但是,除了以下內容之外,我沒有得到任何輸出:

Welcome to minicom 2.7

OPTIONS: I18n 
Compiled on Jan  1 2014, 17:13:22.
Port /dev/ttyUSB0, 15:02:26

Press CTRL-A Z for help on special keys

CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.7 | VT102 | Offline | ttyUSB0            

我認為問題出在離線狀態?

答案1

看到這部分...

F - 硬體流量控制:是

將其更改為“否”(或關閉...無論如何)並重新啟動 minicom。

答案2

當您拔出並重新插入 USB 時,裝置中的 USB 會變更為/dev/ttyUSB1/dev/ttyUSB2取決於您重新插入 USB 的次數。嘗試連接其他裝置。

從錯誤來看 ,我相信當您重新插入 USB 時,ls: cannot access /dev/ttyUSB0: No such file or directory終端控制器已更改。/dev/ttyUSBX

答案3

ls /dev/ttyUSB*在那時sudo minicom -D /dev/ttyUSBx

您也可以使用我的 shell 腳本在新終端機中開啟所有 minicom:

#!/bin/bash  

open_minicom(){
PORT_IP=2
PORT_IP=$((PORT_IP+$1))
gnome-terminal -t "Minicom port $1 - 192.168.1.$PORT_IP" -x ./tmp_script"$1".sh
#./minicom_PORT.sh "$PORT_NUM"
}

generate_script(){
echo "$1"
PORT_NUM="$1"
PORT_IP=2
PORT_IP=$((PORT_IP+$1))
#gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "Minicom port $PORT_NUM"
#############################generat script
touch tmp_script"$1".sh
chmod 777 tmp_script"$1".sh
cat <<EOT >> tmp_script"$1".sh
#!/usr/bin/expect -f
spawn sudo minicom -D /dev/ttyUSB$PORT_NUM -S set_ip"$PORT_IP".sh
expect {
-re ".*sword.*" {
    exp_send "$pass\r"
}
}
interact
EOT
###############################
#open terminal
}

generate_eth(){
PORT_IP=2
PORT_IP=$((PORT_IP+$1))
touch set_ip"$PORT_IP".sh
chmod 777 set_ip"$PORT_IP".sh
cat <<EOT >> set_ip"$PORT_IP".sh
#!/bin/bash
ifconfig eth0 192.168.1.$PORT_IP down up
EOT
}

MY_distractor(){
rm tmp_script*.sh set_ip*.sh
}


#printf "\n$NUM_OF_PORTS\n"
##############################
#             MAIN           #
##############################
NUM_OF_PORTS="$(ls /dev/ttyUSB* | grep -v ^l | wc -l)"
if [ $# -eq 0 ]
  then
    printf "No password arguments supplied\n Plase run ./your_script password \n Exiting......\n" && exit 1;
else
    pass="$1"
fi
if [ "$NUM_OF_PORTS" == "0" ]; then
    printf "Not found any minicom ports\n Exiting......\n" && exit 1;
fi
for (( i=0; i < $NUM_OF_PORTS ; i++ ))
do
    generate_script "$i"
done
echo "$(ls tmp_script*.sh)"
for (( i=0; i < $NUM_OF_PORTS ; i++ ))
do
    generate_eth "$i"
done

for (( i=0; i < $NUM_OF_PORTS ; i++ ))
do
    open_minicom "$i"
done
sleep 1

MY_distractor

相關內容