mirror of
https://github.com/lowobservable/oec.git
synced 2026-02-27 01:00:13 +00:00
Use open_serial_interface
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import os
|
||||
import time
|
||||
import signal
|
||||
import logging
|
||||
import argparse
|
||||
from contextlib import contextmanager
|
||||
from serial import Serial
|
||||
from coax import SerialInterface
|
||||
from coax import open_serial_interface
|
||||
|
||||
from .controller import Controller
|
||||
from .tn3270 import TN3270Session
|
||||
@@ -36,23 +33,6 @@ def _get_keymap(terminal_id, extended_id):
|
||||
|
||||
return keymap
|
||||
|
||||
@contextmanager
|
||||
def _create_interface(args):
|
||||
with Serial(args.serial_port, 115200) as serial:
|
||||
serial.reset_input_buffer()
|
||||
serial.reset_output_buffer()
|
||||
|
||||
# Allow the interface firmware time to start, this is only required for the
|
||||
# original Arduino Mega based interface.
|
||||
if 'COAX_FAST_START' not in os.environ:
|
||||
time.sleep(3)
|
||||
|
||||
interface = SerialInterface(serial)
|
||||
|
||||
interface.reset()
|
||||
|
||||
yield interface
|
||||
|
||||
def _create_session(args, terminal):
|
||||
if args.emulator == 'tn3270':
|
||||
return TN3270Session(terminal, args.host, args.port)
|
||||
@@ -104,7 +84,7 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with _create_interface(args) as interface:
|
||||
with open_serial_interface(args.serial_port) as interface:
|
||||
create_session = lambda terminal: _create_session(args, terminal)
|
||||
|
||||
controller = Controller(interface, _get_keymap, create_session)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
more-itertools==8.7.0
|
||||
ptyprocess==0.7.0
|
||||
pycoax==0.8.0
|
||||
pycoax==0.9.0
|
||||
pyserial==3.5
|
||||
pyte==0.8.0
|
||||
pytn3270==0.10.0
|
||||
|
||||
Reference in New Issue
Block a user