scripts: Change kshell from PTY device to socket connection
Use the socket connection instead of PTY so there's no FIFO deadlock
created by the unconnected PTY device during the robot test.
Change-Id: Iab5829ac2c52822ec1dacfa37817cf9637f43c88
diff --git a/create-kshell-device.sh b/create-kshell-device.sh
deleted file mode 100755
index 8ec63a9..0000000
--- a/create-kshell-device.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /bin/bash
-# Create kata shell pty device based on the renode port number as the input
-# argument.
-
-TERM_PORT=${1:-0}
-if [[ ${TERM_PORT} -gt 0 ]]; then
- TERM_DEV="/tmp/term${TERM_PORT}"
-elif [[ ${TERM_PORT} -eq 0 ]]; then
- TERM_DEV="/tmp/term"
-else
- TERM_DEV="/tmp/term1337"
-fi
-
-echo "${TERM_DEV}"
diff --git a/create-kshell-socket-port.sh b/create-kshell-socket-port.sh
new file mode 100755
index 0000000..5d42aaa
--- /dev/null
+++ b/create-kshell-socket-port.sh
@@ -0,0 +1,12 @@
+#! /bin/bash
+# Create kata shell socket port based on the renode port number as the input
+# argument.
+
+TERM_PORT=${1:-0}
+if [[ ${TERM_PORT} -ge 0 ]]; then
+ SOCKET_PORT=$((${TERM_PORT} + 3456))
+else
+ SOCKET_PORT=1337
+fi
+
+echo "${SOCKET_PORT}"
diff --git a/generate-renode-port-cmd.sh b/generate-renode-port-cmd.sh
index 19dce0b..85de006 100755
--- a/generate-renode-port-cmd.sh
+++ b/generate-renode-port-cmd.sh
@@ -5,7 +5,7 @@
PORT=${1:-1234}
DIR_NAME=$(dirname $(realpath $0))
TERM_PORT_INPUT=$((${PORT} - 1234))
-TERM_DEV=$(${DIR_NAME}/create-kshell-device.sh ${TERM_PORT_INPUT})
+SOCKET_PORT=$("${DIR_NAME}/create-kshell-socket-port.sh" ${TERM_PORT_INPUT})
if [[ ${TERM_PORT_INPUT} -ge 0 ]]; then
GDB_PORT=$((${TERM_PORT_INPUT} + 3333))
@@ -13,4 +13,4 @@
GDB_PORT=4670 # 3333 + 1337
fi
-echo "\\\$term_port = \\\"${TERM_DEV}\\\"; \\\$gdb_port = ${GDB_PORT};"
+echo "\\\$term_port = ${SOCKET_PORT}; \\\$gdb_port = ${GDB_PORT};"
diff --git a/kshell.sh b/kshell.sh
index 17a1b20..5dc744a 100755
--- a/kshell.sh
+++ b/kshell.sh
@@ -4,6 +4,6 @@
PORT=${1:-1234}
DIR_NAME=$(dirname $(realpath $0))
TERM_PORT_INPUT=$((${PORT} - 1234))
-TERM_DEV=$(${DIR_NAME}/create-kshell-device.sh ${TERM_PORT_INPUT})
-echo "Access ${TERM_DEV}"
-stty sane -echo -icanon; socat - "${TERM_DEV}",raw; stty sane
+SOCKET_PORT=$("${DIR_NAME}/create-kshell-socket-port.sh" ${TERM_PORT_INPUT})
+echo "Access port: ${SOCKET_PORT}"
+stty sane -echo -icanon; socat "TCP:localhost:${SOCKET_PORT}" -; stty sane