From fddad7f080fb7f5a54e6dbfc5acaecda87f1f1c5 Mon Sep 17 00:00:00 2001 From: Links Date: Sat, 16 Apr 2022 10:26:10 +0200 Subject: [PATCH] add network CAT control --- README.md | 25 +++++++++- userpatches/customize-image.sh | 9 ++++ .../etc/systemd/system/usbc_port_cat.service | 12 +++++ .../etc/systemd/system/x6100_app.service | 1 + .../etc/systemd/system/x6100_cat_mux.service | 12 +++++ .../systemd/system/x6100_socat_cat.service | 13 +++++ userpatches/overlay/root/run_x6100_app.sh | 25 ++++++++++ .../overlay/root/run_x6100_socat_app.sh | 47 +++++++++++++++++++ 8 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 userpatches/overlay/etc/systemd/system/usbc_port_cat.service create mode 100644 userpatches/overlay/etc/systemd/system/x6100_cat_mux.service create mode 100644 userpatches/overlay/etc/systemd/system/x6100_socat_cat.service create mode 100755 userpatches/overlay/root/run_x6100_socat_app.sh diff --git a/README.md b/README.md index d8f16e9..da06c5a 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,31 @@ with armbian booted the X6100 will open a TCP server on port 7000 to allow acces this will create a `X6100_RX.monitor` pulse device and connect in to the X6100 ```sh +export X6100_IP= pactl load-module module-null-sink sink_name=X6100_RX sink_properties=device.description=X6100_RX -gst-launch-1.0 tcpclientsrc port=7000 host= ! audio/x-raw,rate=16000,channels=2,format=S16LE ! pulsesink device=X6100_RX client-name=X6100 +gst-launch-1.0 tcpclientsrc port=7000 host=${X6100_IP} ! audio/x-raw,rate=16000,channels=2,format=S16LE ! pulsesink device=X6100_RX client-name=X6100 +``` + +# CAT via Network + +the X6100 runs a `rigctld` on TCP port 4532. + +for RAW Serial access via Network us TCP port 9990. + +## Virtual Serial port on Linux +```sh +export X6100_IP= +sudo socat pty,link=/dev/ttyX6100Cat,raw,echo=0,user=${USER} tcp:${X6100_IP}:9990 +``` + +# Xorg + +## virtual FHD + +for setting up the screen with a virtual FHD resulution + +```sh +xrandr --output None-1 --mode 480x800 --panning 1920x1080 ``` # build steps diff --git a/userpatches/customize-image.sh b/userpatches/customize-image.sh index c3fc54b..35da6c1 100644 --- a/userpatches/customize-image.sh +++ b/userpatches/customize-image.sh @@ -72,10 +72,19 @@ Main() { # startup systemctl enable x6100_chroot.service + systemctl enable x6100_socat_cat.service systemctl enable x6100_app.service systemctl enable lightdm_x6100.service systemctl enable novnc.service + wget https://github.com/Links2004/x6100-cat-mux/releases/download/1.0.2/x6100_cat_mux -O /root/x6100_cat_mux + chmod +x /root/x6100_cat_mux + + systemctl enable x6100_cat_mux.service + systemctl enable rigctld_socat.service + systemctl enable rigctld.service + systemctl enable usbc_port_cat.service + # disable not needed services systemctl disable smbd.service diff --git a/userpatches/overlay/etc/systemd/system/usbc_port_cat.service b/userpatches/overlay/etc/systemd/system/usbc_port_cat.service new file mode 100644 index 0000000..cbf1035 --- /dev/null +++ b/userpatches/overlay/etc/systemd/system/usbc_port_cat.service @@ -0,0 +1,12 @@ +[Unit] +Description=USB-C Port RAW CAT control +Requires=x6100_socat_cat.service +Requires=x6100_cat_mux.service + +[Service] +User=root +ExecStart=/usr/bin/socat /dev/ttyS2_USB_CAT,b19200,raw,echo=0 tcp:127.0.0.1:9090 +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/userpatches/overlay/etc/systemd/system/x6100_app.service b/userpatches/overlay/etc/systemd/system/x6100_app.service index 731f84d..4f4f53e 100644 --- a/userpatches/overlay/etc/systemd/system/x6100_app.service +++ b/userpatches/overlay/etc/systemd/system/x6100_app.service @@ -3,6 +3,7 @@ Description=x6100 APP Requires=x6100_chroot.service Requires=amixer.service Requires=gpio_setup.service +Requires=x6100_socat_cat.service ConditionKernelCommandLine=x6100_app=1 [Service] diff --git a/userpatches/overlay/etc/systemd/system/x6100_cat_mux.service b/userpatches/overlay/etc/systemd/system/x6100_cat_mux.service new file mode 100644 index 0000000..4d3684d --- /dev/null +++ b/userpatches/overlay/etc/systemd/system/x6100_cat_mux.service @@ -0,0 +1,12 @@ +[Unit] +Description=x6100 CAT MUX Server +Requires=x6100_chroot.service +Requires=x6100_socat_cat.service + +[Service] +User=root +ExecStart=/root/x6100_cat_mux +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/userpatches/overlay/etc/systemd/system/x6100_socat_cat.service b/userpatches/overlay/etc/systemd/system/x6100_socat_cat.service new file mode 100644 index 0000000..df5fe8e --- /dev/null +++ b/userpatches/overlay/etc/systemd/system/x6100_socat_cat.service @@ -0,0 +1,13 @@ +[Unit] +Description=x6100 CAT redirect +Requires=x6100_chroot.service + +[Service] +User=root +ExecStart=/root/run_x6100_socat_app.sh start +ExecStop=/root/run_x6100_socat_app.sh stop +Restart=on-failure + +[Install] +WantedBy=multi-user.target + diff --git a/userpatches/overlay/root/run_x6100_app.sh b/userpatches/overlay/root/run_x6100_app.sh index 88d6166..32f5ebe 100755 --- a/userpatches/overlay/root/run_x6100_app.sh +++ b/userpatches/overlay/root/run_x6100_app.sh @@ -1,7 +1,19 @@ #!/bin/bash +set -e + +CAT_DEV=/dev/ttyS2 +CAT_DEV_NEW=/dev/ttyS2_VIRT + function cleanup() { echo 0 > /sys/class/gpio/gpio138/value + + if [ -e "/mnt/x6100/${CAT_DEV}" ] ; then + umount /mnt/x6100/${CAT_DEV} || true + fi + if [ -f "/mnt/x6100/${CAT_DEV}" ] ; then + rm /mnt/x6100/${CAT_DEV} + fi } trap cleanup EXIT @@ -30,5 +42,18 @@ else EOL fi +until [ -e ${CAT_DEV_NEW} ] ; do + echo "waiting for ${CAT_DEV_NEW}" + sleep 1 +done + +if [ -e "/mnt/x6100/${CAT_DEV}" ] ; then + umount /mnt/x6100/${CAT_DEV} || true +fi + +touch /mnt/x6100/${CAT_DEV} +mount -o bind ${CAT_DEV_NEW} /mnt/x6100${CAT_DEV} + echo 1 > /sys/class/gpio/gpio138/value + chroot /mnt/x6100 /bin/bash -c 'source /etc/profile && nice --5 /usr/app_qt/x6100_ui_v100' diff --git a/userpatches/overlay/root/run_x6100_socat_app.sh b/userpatches/overlay/root/run_x6100_socat_app.sh new file mode 100755 index 0000000..3ea058f --- /dev/null +++ b/userpatches/overlay/root/run_x6100_socat_app.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +ACTION=start + +CAT_DEV=/dev/ttyS2 +CAT_DEV_NEW=/dev/ttyS2_VIRT +CAT_DEV_ORG=/dev/ttyS2_USB_CAT + +if [ "$1" != "" ] ; then + ACTION=$1 +fi + +if [ "$ACTION" == "start" ] ; then + if [ -e "${CAT_DEV}" ] ; then + rm ${CAT_DEV} + fi + if [ -e "${CAT_DEV_NEW}" ] ; then + rm ${CAT_DEV_NEW} + fi + + if [ ! -e "${CAT_DEV_ORG}" ] ; then + # create orginal + mknod -m 660 ${CAT_DEV_ORG} c 4 66 + chown root:dialout ${CAT_DEV_ORG} + fi + + exec socat pty,link=${CAT_DEV_NEW},raw,user=root,group=dialout,echo=0 tcp-listen:9990,bind=127.0.0.1,fork +else + if [ -e "${CAT_DEV_ORG}" ] ; then + rm ${CAT_DEV_ORG} + fi + if [ -e "${CAT_DEV}" ] ; then + rm ${CAT_DEV} + fi + if [ -e "${CAT_DEV_NEW}" ] ; then + rm ${CAT_DEV_NEW} + fi + + if [ -e "/mnt/x6100/${CAT_DEV}" ] ; then + umount /mnt/x6100/${CAT_DEV} + fi + # restore orginal + mknod -m 660 ${CAT_DEV} c 4 66 + chown root:dialout ${CAT_DEV} + +fi