Change handling of input tty

This commit is contained in:
Marc Baloup 2022-12-07 16:31:32 +01:00
parent cc175f7a75
commit 1fb1a6bf5b
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
6 changed files with 23 additions and 7 deletions

9
.idea/TICLinky.iml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/TICLinky.iml" filepath="$PROJECT_DIR$/.idea/TICLinky.iml" />
</modules>
</component>
</project>

View File

@ -9,8 +9,7 @@ ENV TIC_MQTT_SERVER_IP="127.0.0.1"
ENV TIC_MQTT_HASS_DISCOVERY_PREFIX="homeassistant" ENV TIC_MQTT_HASS_DISCOVERY_PREFIX="homeassistant"
ENV TIC_MQTT_USERNAME="name" ENV TIC_MQTT_USERNAME="name"
ENV TIC_MQTT_PASSWORD="pass" ENV TIC_MQTT_PASSWORD="pass"
ENV TIC_TTY_INPUT="/dev/ttyAMA0"
WORKDIR /data/workdir WORKDIR /data/workdir
ENTRYPOINT /data/bin/run.sh -i ENTRYPOINT ["/data/bin/run.sh", "-i"]

View File

@ -9,8 +9,7 @@ services:
TIC_MQTT_HASS_DISCOVERY_PREFIX: "homeassistant" TIC_MQTT_HASS_DISCOVERY_PREFIX: "homeassistant"
TIC_MQTT_USERNAME: "username" TIC_MQTT_USERNAME: "username"
TIC_MQTT_PASSWORD: "password" TIC_MQTT_PASSWORD: "password"
TIC_TTY_INPUT: "/dev/ttyAMA0"
devices: devices:
- "/dev/ttyAMA0:/dev/ttyAMA0" - "/dev/ttyAMA0:/dev/ttyTIC"
volumes: volumes:
- "./workdir:/data/workdir" - "./workdir:/data/workdir"

5
run.sh
View File

@ -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. # 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 # Please use update.sh instead
ls -la $TIC_TTY_INPUT ls -la /dev/ttyTIC
echo "Initializing serial port" 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" echo "Starting TIC server"
java -cp res -jar /data/bin/tic.jar java -cp res -jar /data/bin/tic.jar

View File

@ -20,7 +20,7 @@ public class TICRawDecoder extends Thread {
static final char SEP_SP = 0x20; static final char SEP_SP = 0x20;
static final char SEP_HT = 0x09; 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 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 static final long CORRUPTION_LEVEL_DECAY_INTERVAL = 5000; // interval in ms between each corruption level decrement