very quick and dirty stuff commited
This commit is contained in:
-104
@@ -1,104 +0,0 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
@@ -1,2 +0,0 @@
|
||||
websockets
|
||||
pyserial
|
||||
@@ -1,42 +0,0 @@
|
||||
import serial
|
||||
import asyncio
|
||||
import websockets
|
||||
import sys
|
||||
|
||||
ser = None # serial connection
|
||||
ws = None # websocket connection
|
||||
|
||||
|
||||
async def bridge(url, tty, speed):
|
||||
"Initializes connection to websocket and local serial port"
|
||||
global ser, ws
|
||||
|
||||
ser = serial.Serial(tty, speed, parity=serial.PARITY_EVEN,
|
||||
bytesize=7, timeout=1)
|
||||
ws = await websockets.connect(url)
|
||||
ser.write(b'\x07\x0c\x1f\x40\x41connexion\x0a')
|
||||
# cancel local echo (keyboard > modem > screen)
|
||||
ser.write(b'\x1b\x3b\x60\x58\x52')
|
||||
|
||||
|
||||
async def w2m():
|
||||
"websocket > minitel"
|
||||
while (True):
|
||||
data = await ws.recv()
|
||||
ser.write(data.encode())
|
||||
|
||||
|
||||
async def m2w():
|
||||
"websocket < minitel"
|
||||
while (True):
|
||||
if ser.inWaiting() > 0:
|
||||
tosend = ser.read(ser.inWaiting()).decode()
|
||||
await ws.send(tosend)
|
||||
else:
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(bridge(sys.argv[1], sys.argv[2], sys.argv[3]))
|
||||
loop.run_until_complete(asyncio.gather(w2m(), m2w()))
|
||||
Reference in New Issue
Block a user