From 1fb1a6bf5b62d7696d84ff5743464612063f1c8e Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Wed, 7 Dec 2022 16:31:32 +0100 Subject: [PATCH] Change handling of input tty --- .idea/TICLinky.iml | 9 +++++++++ .idea/modules.xml | 8 ++++++++ Dockerfile | 3 +-- docker-compose-example.yml | 3 +-- run.sh | 5 +++-- src/main/java/fr/mbaloup/home/tic/TICRawDecoder.java | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 .idea/TICLinky.iml create mode 100644 .idea/modules.xml diff --git a/.idea/TICLinky.iml b/.idea/TICLinky.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/TICLinky.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..615375d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index adffbc8..3a5d66e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,7 @@ ENV TIC_MQTT_SERVER_IP="127.0.0.1" ENV TIC_MQTT_HASS_DISCOVERY_PREFIX="homeassistant" ENV TIC_MQTT_USERNAME="name" ENV TIC_MQTT_PASSWORD="pass" -ENV TIC_TTY_INPUT="/dev/ttyAMA0" WORKDIR /data/workdir -ENTRYPOINT /data/bin/run.sh -i \ No newline at end of file +ENTRYPOINT ["/data/bin/run.sh", "-i"] \ No newline at end of file diff --git a/docker-compose-example.yml b/docker-compose-example.yml index 9af2685..21ae274 100644 --- a/docker-compose-example.yml +++ b/docker-compose-example.yml @@ -9,8 +9,7 @@ services: TIC_MQTT_HASS_DISCOVERY_PREFIX: "homeassistant" TIC_MQTT_USERNAME: "username" TIC_MQTT_PASSWORD: "password" - TIC_TTY_INPUT: "/dev/ttyAMA0" devices: - - "/dev/ttyAMA0:/dev/ttyAMA0" + - "/dev/ttyAMA0:/dev/ttyTIC" volumes: - "./workdir:/data/workdir" diff --git a/run.sh b/run.sh index 9efc6b3..24e2e2d 100755 --- a/run.sh +++ b/run.sh @@ -3,9 +3,10 @@ # The run.sh file must be the entry point of the docker container. It is not meant to be run by a user it a terminal. # Please use update.sh instead -ls -la $TIC_TTY_INPUT +ls -la /dev/ttyTIC echo "Initializing serial port" -stty -F $TIC_TTY_INPUT 9600 raw cs7 parenb +stty -F /dev/ttyTIC 9600 raw cs7 parenb & # make it async so if it locks, it doesnt lock everything +sleep 1 echo "Starting TIC server" java -cp res -jar /data/bin/tic.jar diff --git a/src/main/java/fr/mbaloup/home/tic/TICRawDecoder.java b/src/main/java/fr/mbaloup/home/tic/TICRawDecoder.java index 3cc5e89..0ec9a67 100644 --- a/src/main/java/fr/mbaloup/home/tic/TICRawDecoder.java +++ b/src/main/java/fr/mbaloup/home/tic/TICRawDecoder.java @@ -20,7 +20,7 @@ public class TICRawDecoder extends Thread { static final char SEP_SP = 0x20; static final char SEP_HT = 0x09; - static final String INPUT_PATH = System.getenv("TIC_TTY_INPUT"); + static final String INPUT_PATH = "/dev/ttyTIC"; static final int CORRUPTION_MAX_LEVEL = 10; // max number of corruption detected while reading raw input static final long CORRUPTION_LEVEL_DECAY_INTERVAL = 5000; // interval in ms between each corruption level decrement