neuer Modus "minibtx", reagiert auf 0x01 und 0x00 eines miniBtx bei der Anwahl
This commit is contained in:
parent
9a2e2456c9
commit
fb27299f51
2
cept.py
2
cept.py
@ -65,7 +65,7 @@ btxlogo = (
|
|||||||
"\x1b\x7e" # Zeichensatz G1 rechts
|
"\x1b\x7e" # Zeichensatz G1 rechts
|
||||||
"\x9b\x31\x40" # Farbtafel 1 (Halbtöne)
|
"\x9b\x31\x40" # Farbtafel 1 (Halbtöne)
|
||||||
"\x1b\x23\x20\x54" # ganzer Schirm blau
|
"\x1b\x23\x20\x54" # ganzer Schirm blau
|
||||||
"\x1f\x3d1# 200961a\x1f\x2f" # Link zur Demo-Startseite 200961a
|
"\x1f\x3d1# 0a\x1f\x2f" # Link zur Startseite 0
|
||||||
"\x1f\x43\x48\xb8\xa3\x12\x57\xe4"
|
"\x1f\x43\x48\xb8\xa3\x12\x57\xe4"
|
||||||
"\x1f\x44\x47\xea\xa0\x12\x59\xb5"
|
"\x1f\x44\x47\xea\xa0\x12\x59\xb5"
|
||||||
"\x1f\x45\x47\xea \xe0\xf8\xfc\xdf\x12\x49\xfc\xf4\xb0 \xb5"
|
"\x1f\x45\x47\xea \xe0\xf8\xfc\xdf\x12\x49\xfc\xf4\xb0 \xb5"
|
||||||
|
10
config.py
10
config.py
@ -19,13 +19,15 @@ PAGES=[
|
|||||||
LOGLEVEL=logging.DEBUG
|
LOGLEVEL=logging.DEBUG
|
||||||
|
|
||||||
## serial port settings:
|
## serial port settings:
|
||||||
PORT="/dev/pts/5"
|
#PORT="/dev/pts/5"
|
||||||
#PORT="/dev/ttyUSB0"
|
PORT="/dev/ttyUSB3"
|
||||||
BAUDRATE="2400"
|
BAUDRATE="1200"
|
||||||
# if the system is connected directly (null-modem): MODE=direct
|
# if the system is connected directly (null-modem): MODE=direct
|
||||||
# if the system is connected via a modem: MODE=modem
|
# if the system is connected via a modem: MODE=modem
|
||||||
|
# if the system is connected to a miniBtx module: MODE=minibtx
|
||||||
#MODE="modem"
|
#MODE="modem"
|
||||||
MODE="direct"
|
#MODE="direct"
|
||||||
|
MODE="minibtx"
|
||||||
# the init strings for the modem, sent serially at startup
|
# the init strings for the modem, sent serially at startup
|
||||||
MODEM_INIT1="AT&F"
|
MODEM_INIT1="AT&F"
|
||||||
MODEM_INIT2="AT%B1200/75%C0%E0%G1-J0\\N0&G1"
|
MODEM_INIT2="AT%B1200/75%C0%E0%G1-J0\\N0&G1"
|
||||||
|
2
glob.py
2
glob.py
@ -13,4 +13,6 @@ from rtxPage import rtxPage
|
|||||||
cmdline = ""
|
cmdline = ""
|
||||||
curpage = rtxPage()
|
curpage = rtxPage()
|
||||||
prevpage = rtxPage() # to be able to use ** to go back to last page
|
prevpage = rtxPage() # to be able to use ** to go back to last page
|
||||||
|
|
||||||
ser = serial.Serial()
|
ser = serial.Serial()
|
||||||
|
mode = None
|
||||||
|
27
minibtx.py
Normal file
27
minibtx.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
'''
|
||||||
|
rtx - RetroText
|
||||||
|
minibtx: Funktionen für das miniBtx-Modul
|
||||||
|
by Anna Christina Naß <acn@acn.wtf>
|
||||||
|
released under GPL
|
||||||
|
'''
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import serial
|
||||||
|
import config
|
||||||
|
import logging
|
||||||
|
|
||||||
|
MINIBTX_START = b'\x01'
|
||||||
|
MINIBTX_CONNECT = b'\x00'
|
||||||
|
|
||||||
|
def wait_for_minibtx():
|
||||||
|
connected = False
|
||||||
|
logging.debug("wait_for_minibtx")
|
||||||
|
while not connected:
|
||||||
|
rc = glob.ser.read(1)
|
||||||
|
logging.debug("miniBtx: >%s<", rc)
|
||||||
|
if rc == MINIBTX_START:
|
||||||
|
logging.info("miniBtx starts connection...")
|
||||||
|
if rc == MINIBTX_CONNECT:
|
||||||
|
logging.info("miniBtx connected!")
|
||||||
|
connected = True
|
88
rtx.py
88
rtx.py
@ -13,32 +13,92 @@ import glob # global variables
|
|||||||
import config
|
import config
|
||||||
import rtxHelpers
|
import rtxHelpers
|
||||||
import rtxModem
|
import rtxModem
|
||||||
|
import minibtx
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
import logging
|
import logging
|
||||||
|
import getopt
|
||||||
|
import sys
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
# configure the logging format
|
# configure the logging format
|
||||||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=config.LOGLEVEL, datefmt='%Y-%m-%d %I:%M:%S')
|
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=config.LOGLEVEL, datefmt='%Y-%m-%d %I:%M:%S')
|
||||||
|
|
||||||
|
# read command line parameters
|
||||||
|
def OptionsError():
|
||||||
|
""" Fehler beim Kommandozeilenparameter """
|
||||||
|
print("Aufrufparamter:\n -d [device] -m [direct|modem|minibtx] -b [baudrate]")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
localport = None
|
||||||
|
localmode = None
|
||||||
|
localbaud = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.gnu_getopt(sys.argv[1:], 'd:m:b:')
|
||||||
|
except getopt.GetoptError as err:
|
||||||
|
OptionsError()
|
||||||
|
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == "-d":
|
||||||
|
localport = arg
|
||||||
|
if opt == "-m":
|
||||||
|
localmode = arg
|
||||||
|
if opt == "-b":
|
||||||
|
localbaud = arg
|
||||||
|
|
||||||
|
if localbaud:
|
||||||
|
if not localbaud.isdigit():
|
||||||
|
OptionsError()
|
||||||
|
if localmode:
|
||||||
|
if not localmode in ("direct","modem","minibtx"):
|
||||||
|
OptionsError()
|
||||||
|
|
||||||
# initialize serial connection to client
|
# initialize serial connection to client
|
||||||
logging.debug("Serial port %s, Baud rate %s", config.PORT, config.BAUDRATE)
|
if localport is not None:
|
||||||
glob.ser = serial.Serial(config.PORT, config.BAUDRATE, timeout=None, rtscts=True, dsrdtr=True)
|
serport = localport
|
||||||
logging.info("Serial port %s opened", glob.ser.name)
|
else:
|
||||||
|
serport = config.PORT
|
||||||
|
if localbaud is not None:
|
||||||
|
serbaud = localbaud
|
||||||
|
else:
|
||||||
|
serbaud = config.BAUDRATE
|
||||||
|
if localmode is not None:
|
||||||
|
glob.mode = localmode
|
||||||
|
else:
|
||||||
|
glob.mode = config.MODE
|
||||||
|
|
||||||
|
logging.debug("Serial port %s, Baud rate %s", serport, serbaud)
|
||||||
|
|
||||||
|
if glob.mode == "direct" or glob.mode == "modem":
|
||||||
|
glob.ser = serial.Serial(serport, serbaud, timeout=None, rtscts=True, dsrdtr=True)
|
||||||
|
elif glob.mode == "minibtx":
|
||||||
|
glob.ser = serial.Serial(serport, serbaud, timeout=None, bytesize=8, parity='N', stopbits=2, rtscts=False, dsrdtr=False)
|
||||||
|
else:
|
||||||
|
logging.error("wrong mode: %s - this should not happen", glob.mode)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
#glob.ser = serial.Serial(config.PORT, config.BAUDRATE, timeout=None, rtscts=True, dsrdtr=True)
|
||||||
|
glob.ser = serial.Serial(config.PORT, config.BAUDRATE, timeout=None, bytesize=8, parity='N', stopbits=2, rtscts=False, dsrdtr=False)
|
||||||
|
|
||||||
|
logging.debug("Serial port %s opened", glob.ser.name)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if config.MODE=="modem":
|
if glob.mode == "modem":
|
||||||
rtxModem.init_modem()
|
rtxModem.init_modem()
|
||||||
rtxModem.wait_for_caller()
|
rtxModem.wait_for_caller()
|
||||||
rtxHelpers.send_welcome_page()
|
rtxHelpers.send_welcome_page()
|
||||||
|
elif glob.mode == "minibtx":
|
||||||
|
minibtx.wait_for_minibtx()
|
||||||
|
rtxHelpers.send_welcome_page()
|
||||||
|
|
||||||
# main loop to read data from client
|
# main loop to read data from client
|
||||||
while True:
|
while True:
|
||||||
in_byte = glob.ser.read(1)
|
in_byte = glob.ser.read(1)
|
||||||
rtxHelpers.process_byte(in_byte)
|
rtxHelpers.process_byte(in_byte)
|
||||||
if config.MODE == "modem":
|
if glob.mode == "modem":
|
||||||
if glob.ser.getCD() == False:
|
if glob.ser.getCD() == False:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ def process_byte(in_byte):
|
|||||||
"""
|
"""
|
||||||
instr=str(in_byte, encoding="latin-1")
|
instr=str(in_byte, encoding="latin-1")
|
||||||
|
|
||||||
if config.MODE=="modem":
|
if glob.mode=="modem":
|
||||||
logging.debug("> %s < CD: %s", instr, glob.ser.getCD())
|
logging.debug("> %s < CD: %s", instr, glob.ser.getCD())
|
||||||
|
|
||||||
# what to send back to the client
|
# what to send back to the client
|
||||||
|
@ -80,7 +80,7 @@ class rtxMask:
|
|||||||
# read input and interpret it
|
# read input and interpret it
|
||||||
while weiter==True:
|
while weiter==True:
|
||||||
# if the modem hangs up, exit the function:
|
# if the modem hangs up, exit the function:
|
||||||
#if config.MODE == "modem" and glob.ser.getCD() == False:
|
#if glob.mode == "modem" and glob.ser.getCD() == False:
|
||||||
# weiter=False
|
# weiter=False
|
||||||
in_byte = glob.ser.read(1)
|
in_byte = glob.ser.read(1)
|
||||||
instr = str(in_byte, encoding="latin-1")
|
instr = str(in_byte, encoding="latin-1")
|
||||||
|
Loading…
Reference in New Issue
Block a user