Add support for containers and simulation

This commit is contained in:
2022-01-02 16:23:35 +01:00
parent 25d8c4a3bb
commit ad86a39219
7 changed files with 35 additions and 0 deletions

1
.gitignore vendored
View File

@@ -130,3 +130,4 @@ dmypy.json
*.swp
dcc/media
arduino/CommandStation-EX/build/

8
daemons/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM python:3.10-alpine
RUN mkdir /opt/dcc && pip -q install pyserial
ADD net-to-serial.py config.ini /opt/dcc
EXPOSE 2560/tcp
CMD ["python3", "/opt/dcc/net-to-serial.py"]

1
daemons/net-to-serial.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import logging
import serial
import asyncio

Binary file not shown.

View File

@@ -0,0 +1,7 @@
FROM dcc/net-to-serial
RUN apk update && apk add qemu-system-avr && mkdir /io
ADD start.sh /opt/dcc
ADD CommandStation-EX-uno-*.elf /io
CMD ["/bin/sh", "/opt/dcc/start.sh"]

View File

@@ -0,0 +1,6 @@
# AVR Simulator
```bash
$ podman build -t dcc/net-to-serial:sim .
$ podman run -d -p2560:2560 dcc/net-to-serial:sim
```

12
daemons/simulator/start.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
PTY=0
if [ -c /dev/pts/0 ]; then
PTY=1
fi
sed -i "s/ttyACM0/pts\/${PTY}/" /opt/dcc/config.ini
qemu-system-avr -machine uno -bios /io/CommandStation-EX-uno-*.elf -serial pty -daemonize
/opt/dcc/net-to-serial.py