steptail.com

Who put the alphabet in alphabetical order?

User Tools

Site Tools


guides:virtual_modem:script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
guides:virtual_modem:script [2022-12-20 06:19]
omolini
guides:virtual_modem:script [2022-12-28 03:32]
omolini
Line 34: Line 34:
 # o PuTTY # o PuTTY
 # #
-# PPP connectivity ​will initialize ​correctly ​under the following configurations:​+# PPP dial-up ​connectivity ​tested to initialize under the following configurations:​
 # #
-# o Microsoft ​Windows 3.1 +# o Windows 3.1 
-#   - Trumpet Winsock+#   - Trumpet Winsock ​3.0 revision D
 # #
-# o Microsoft ​Windows 95 OSR 2.5 + DUN 1.4 +# o Windows 95 OSR 2.5 + DUN 1.4 
-#   - Generic+#   - Generic ​Modem
 #     - Standard 28800 bps Modem #     - Standard 28800 bps Modem
 # #
-# o Microsoft ​Windows 98 +# o Windows 98 
-#   - Generic+#   - Generic ​Modem
 #     - Standard 9 600 bps modem #     - Standard 9 600 bps modem
 #     - Standard 33 600 bps modem #     - Standard 33 600 bps modem
Line 50: Line 50:
 #     - Standard 56 000 bps X2 modem #     - Standard 56 000 bps X2 modem
 #     - Standard 56 000 bps K56Flex modem #     - Standard 56 000 bps K56Flex modem
 +#
 +# o Windows 2000
 +#   - Generic Modem
 +#     - Standard 19200 bps Modem
 +#
 +# Help us test and add more supported systems! ​
 +# Contact us on Discord, links at the bottom of the Virtual Modem page.
 # #
  
Line 130: Line 137:
 # SEND MESSAGE ON SCREEN AND OVER SERIAL # SEND MESSAGE ON SCREEN AND OVER SERIAL
 sendtty () { sendtty () {
 +  # Prints message in console and over serial. Message is given as first parameter.
   message="​$1"​   message="​$1"​
   echo -en "​$message"​ | tee /​dev/​$serport   echo -en "​$message"​ | tee /​dev/​$serport
 +}
 +
 +readtty () {
 +  # Reads input from TTY and stores it in variable given as first parameter
 +  line=
 +  while [[ -z "​$line"​ ]]; do
 +    charhex=`head -c 1 /​dev/​$serport | xxd -p -`
 +    char="​`echo -e "​\x$charhex"​`"​
 +    echo -n "​$char"​
 +    echo -n "​$char"​ > /​dev/​$serport
 +    # Newline received
 +    if [ "​$charhex"​ = "​0d"​ -o "​$charhex"​ = "​0a"​ ]; then
 +      line=$buffer
 +      buffer=
 +      char=
 +      sendtty "​\n"​
 +    fi
 +    buffer=$buffer$char
 +  done
 +  local __resultvar=$1
 +  local result="​$line"​
 +  eval $__resultvar="'​$result'"​
 } }
  
 export -f sendtty export -f sendtty
 +export -f readtty
 export -f ttyinit export -f ttyinit
  
Line 143: Line 174:
  
 sendtty "​\n"​ sendtty "​\n"​
-sendtty "VMODEM - Virtual Modem bootstrap for PPP link v$vmodver\n"​ +sendtty "​Virtual Modem bootstrap for PPP link v$vmodver\n"​ 
-sendtty "​Connection speed set to $baud baud\n"​+sendtty "​Connection speed set to $baud baud.\n" 
 +sendtty "My current IP address is $(hostname -I).\n"
 sendtty "​\n"​ sendtty "​\n"​
-sendtty "TYPE HELP FOR COMMANDS\n"+sendtty "​TYPE ​\"HELP\" ​FOR COMMAND REFERENCE.\n"
 sendtty "​READY.\n"​ sendtty "​READY.\n"​
  
Line 433: Line 465:
       sendtty "​General commands:​\n"​       sendtty "​General commands:​\n"​
       sendtty "​HELP.......Display this help\n"​       sendtty "​HELP.......Display this help\n"​
-      sendtty "​LOGIN......Fork a new linux login on serial\n"+      sendtty "​LOGIN......Drop to shell\n"
       sendtty "​SETUP......Change settings\n"​       sendtty "​SETUP......Change settings\n"​
       sendtty "​EXIT.......End this script\n"​       sendtty "​EXIT.......End this script\n"​
Line 452: Line 484:
       while true; do       while true; do
         # Display menu         # Display menu
-        ​echo "​System Setup"​ +        ​sendtty "​\n"​ 
-        ​echo "​============"​ +        sendtty ​"​System Setup\n
-        ​echo "1. Change Wireless Network settings"​ +        ​sendtty ​"​============\n
-        ​echo "2. Exit"+        ​sendtty ​"1. Change Wireless Network settings\n
 +        ​sendtty ​"2. Exit\n" 
 +        sendtty "Enter your selection: ​"
         # Read user input         # Read user input
-        ​read -p "Enter your selection: " ​selection+        ​readtty ​selection 
         # Wireless network settings         # Wireless network settings
         if [[ "​$selection"​ == "​1"​ ]]; then         if [[ "​$selection"​ == "​1"​ ]]; then
           while true; do           while true; do
-            ​echo "Wi-Fi Settings"​ +            ​sendtty "​\n"​ 
-            ​echo "​=============="​ +            sendtty ​"Wi-Fi Settings\n
-            ​echo "1. Connect to new Wi-Fi network"​ +            ​sendtty ​"​==============\n
-            ​echo "2. Modify password for current Wi-Fi network"​ +            ​sendtty ​"1. Connect to new Wi-Fi network\n
-            ​echo "3. Disconnect from current Wi-Fi network"​ +            ​sendtty ​"2. Modify password for current Wi-Fi network\n
-            ​echo "4. Display current Wi-Fi connection status"​ +            ​sendtty ​"3. Disconnect from current Wi-Fi network\n
-            ​echo "5. Exit"​ +            ​sendtty ​"4. Display current Wi-Fi connection status\n
 +            ​sendtty ​"5. Exit\n
 +            ​sendtty "Enter your selection: "
             # Read user input             # Read user input
-            ​read -p "Enter your selection: " selection +            ​readtty ​selection
             # Connect to new Wi-Fi network             # Connect to new Wi-Fi network
             if [[ "​$selection"​ == "​1"​ ]]; then             if [[ "​$selection"​ == "​1"​ ]]; then
-              ​read -p "Enter SSID: " ssid +              ​sendtty ​"Enter SSID: " 
-              ​read -p "Enter password: " password+              readtty ​ssid 
 +              ​sendtty ​"Enter password: " 
 +              readtty ​password
               sudo wpa_cli -i wlan0 remove_network 0               sudo wpa_cli -i wlan0 remove_network 0
               sudo wpa_cli -i wlan0 add_network               sudo wpa_cli -i wlan0 add_network
Line 482: Line 519:
               sudo wpa_cli -i wlan0 select_network 0               sudo wpa_cli -i wlan0 select_network 0
               sudo wpa_cli -i wlan0 enable_network 0               sudo wpa_cli -i wlan0 enable_network 0
- 
             # Modify password for current Wi-Fi network             # Modify password for current Wi-Fi network
             elif [[ "​$selection"​ == "​2"​ ]]; then             elif [[ "​$selection"​ == "​2"​ ]]; then
-              ​read -p "Enter new password: " password+              ​sendtty ​"Enter new password: " 
 +              readtty ​password
               sudo wpa_cli -i wlan0 set_network 0 psk "​\"​$password\""​               sudo wpa_cli -i wlan0 set_network 0 psk "​\"​$password\""​
-          ​ 
             # Disconnect from current Wi-Fi network             # Disconnect from current Wi-Fi network
             elif [[ "​$selection"​ == "​3"​ ]]; then             elif [[ "​$selection"​ == "​3"​ ]]; then
 +              sendtty "​Disconnecting from current Wi-Fi network\n"​
               sudo wpa_cli -i wlan0 disable_network 0               sudo wpa_cli -i wlan0 disable_network 0
-          ​ 
             # Display current Wi-Fi connection status             # Display current Wi-Fi connection status
             elif [[ "​$selection"​ == "​4"​ ]]; then             elif [[ "​$selection"​ == "​4"​ ]]; then
               status=$(sudo wpa_cli -i wlan0 status)               status=$(sudo wpa_cli -i wlan0 status)
-              ​echo "​$status"​ +              ​sendtty "​\n"​ 
-          +              sendtty "Wi-fi connection status\n"​ 
 +              sendtty "​=======================\n"​ 
 +              sendtty ​"​$status"​ 
 +              ​sendtty "​\n"​
             # Exit             # Exit
             elif [[ "​$selection"​ == "​5"​ ]]; then             elif [[ "​$selection"​ == "​5"​ ]]; then
               break               break
- 
             # Invalid selection             # Invalid selection
             else             else
-              ​echo "​Invalid selection. Please try again."​+              ​sendtty ​"​Invalid selection. Please try again.\n"
             fi             fi
           done           done
         # Exit         # Exit
         elif [[ "​$selection"​ == "​2"​ ]]; then         elif [[ "​$selection"​ == "​2"​ ]]; then
 +          sendtty "​Exited setup\n"​
 +          sendtty "​READY.\n"​
           break           break
         # Invalid selection         # Invalid selection
         else         else
-          ​echo "​Invalid selection. Please try again."​+          ​sendtty ​"​Invalid selection. Please try again.\n"
         fi         fi
       done       done
Line 635: Line 675:
 sendtty "​\n"​ sendtty "​\n"​
 sendtty "​Please enter your name: \n" sendtty "​Please enter your name: \n"
-read -e -p "User? " ​username+readtty ​username
 sendtty "​\n"​ sendtty "​\n"​
 sendtty "​Hello,​ $username!\n"​ sendtty "​Hello,​ $username!\n"​
guides/virtual_modem/script.txt · Last modified: 2022-12-28 03:32 by omolini