Browse Source

adding PR#1 https://github.com/cquest/websocket2minitel/pull/1/files

Snarf 5 hours ago
parent
commit
b584540b3d
2 changed files with 13 additions and 2 deletions
  1. 4 0
      README.md
  2. 9 2
      websocket2minitel.py

+ 4 - 0
README.md

@@ -16,6 +16,10 @@ pip3 install -r requirements.txt
 
 python3 websocket2minitel.py <websocketURL> <serialPort> <serialSpeed>
 
+minitel in videotext mode 
+
+ex: minipavi : ./websocket2minitel.py 'wss://go.minipavi.fr:8181' /dev/ttyUSB0 4800 
+
 ## Examples
 
 Connect to 3615co.de and display at 1200 bps

+ 9 - 2
websocket2minitel.py

@@ -15,7 +15,7 @@ async def bridge(url, tty, speed):
     ser = serial.Serial(tty, speed, parity=serial.PARITY_EVEN,
                         bytesize=7, timeout=1,stopbits=serial.STOPBITS_ONE,
                         xonxoff=False,rtscts=False)
-    ws = await websockets.connect(url)
+    ws = await websockets.connect(url, ping_interval=None)
     ser.write(b'\x07\x0c\x1f\x40\x41connexion\x0a')
     # cancel local echo (keyboard > modem > screen)
     ser.write(b'\x1b\x3b\x60\x58\x52')
@@ -24,7 +24,14 @@ async def bridge(url, tty, speed):
 async def w2m():
     "websocket > minitel"
     while (True):
-        data = await ws.recv()
+        #data = await ws.recv()
+        try:
+            data = await ws.recv()
+        except websockets.exceptions.ConnectionClosedError:
+            print("Connection closed by remote host.")
+            exit(-1)
+        except websockets.exceptions.ConnectionClosedOK:
+            exit(0)
         ser.write(data.encode())