cosmetic: switch to consistent four-spaces indent (using autopep8)
This commit is contained in:
parent
79c2124e0c
commit
45788b2783
1
peer.py
1
peer.py
|
@ -22,6 +22,7 @@ from typing import Any
|
|||
from construct import Container, Int16ul
|
||||
from proto import DbgMuxFrame
|
||||
|
||||
|
||||
class DbgMuxPeer:
|
||||
def __init__(self, sl):
|
||||
self.tx_count: int = 0
|
||||
|
|
6
proto.py
6
proto.py
|
@ -20,8 +20,10 @@ from construct import *
|
|||
|
||||
import crcmod
|
||||
|
||||
# DebugMux frame definition
|
||||
|
||||
class DbgMuxFrame:
|
||||
''' DebugMux frame definition '''
|
||||
|
||||
# Kudos to Stefan @Sec Zehl for finding the CRC function parameters
|
||||
fcs_func = crcmod.mkCrcFun(0x11021, rev=True, initCrc=0x0, xorOut=0xffff)
|
||||
|
||||
|
@ -30,7 +32,6 @@ class DbgMuxFrame:
|
|||
Ident = 0x66, # 'f'
|
||||
Ping = 0x67, # 'g'
|
||||
Pong = 0x68, # 'h'
|
||||
|
||||
DPAnnounce = 0x69, # 'i'
|
||||
# TODO: = 0x6a, # 'j'
|
||||
ConnEstablish = 0x6b, # 'k'
|
||||
|
@ -38,7 +39,6 @@ class DbgMuxFrame:
|
|||
ConnTerminate = 0x6d, # 'm'
|
||||
ConnTerminated = 0x6e, # 'n'
|
||||
ConnData = 0x6f, # 'o'
|
||||
|
||||
# TODO: = 0x70, # 'p'
|
||||
Ack = 0x71, # 'q'
|
||||
)
|
||||
|
|
30
sedbgmux.py
30
sedbgmux.py
|
@ -28,6 +28,7 @@ import sys
|
|||
from proto import DbgMuxFrame
|
||||
from peer import DbgMuxPeer
|
||||
|
||||
|
||||
class SEDbgMuxApp(cmd2.Cmd):
|
||||
DESC = 'DebugMux client for [Sony] Ericsson phones and modems'
|
||||
|
||||
|
@ -57,18 +58,13 @@ class SEDbgMuxApp(cmd2.Cmd):
|
|||
@cmd2.with_category(CATEGORY_CONN)
|
||||
def do_connect(self, opts) -> None:
|
||||
''' Connect to the modem and switch it to DebugMux mode '''
|
||||
slp = {
|
||||
'port' : self.argv.serial_port,
|
||||
'baudrate' : self.argv.serial_baudrate,
|
||||
'bytesize' : 8,
|
||||
'parity' : 'N',
|
||||
'stopbits' : 1,
|
||||
'timeout' : self.argv.serial_timeout,
|
||||
# 'xonoff' : False,
|
||||
'rtscts' : False,
|
||||
'dsrdtr' : False,
|
||||
}
|
||||
self.sl = serial.Serial(**slp)
|
||||
self.sl = serial.Serial(port=self.argv.serial_port,
|
||||
baudrate=self.argv.serial_baudrate,
|
||||
bytesize=8, parity='N', stopbits=1,
|
||||
timeout=self.argv.serial_timeout,
|
||||
# xonoff=False,
|
||||
rtscts=False,
|
||||
dsrdtr=False)
|
||||
|
||||
# Test the modem
|
||||
self.transceive('AT', 'OK')
|
||||
|
@ -144,7 +140,8 @@ class SEDbgMuxApp(cmd2.Cmd):
|
|||
def do_establish(self, opts) -> None:
|
||||
''' Establish connection with a Data Provider '''
|
||||
log.info("Establishing connection with DPRef=0x%04x", opts.DPRef)
|
||||
self.peer.send(DbgMuxFrame.MsgType.ConnEstablish, dict(DPRef=opts.DPRef))
|
||||
self.peer.send(DbgMuxFrame.MsgType.ConnEstablish,
|
||||
dict(DPRef=opts.DPRef))
|
||||
|
||||
f = self.peer.recv()
|
||||
assert f['MsgType'] == DbgMuxFrame.MsgType.ConnEstablished
|
||||
|
@ -153,7 +150,8 @@ class SEDbgMuxApp(cmd2.Cmd):
|
|||
self.peer.send(DbgMuxFrame.MsgType.Ack)
|
||||
return
|
||||
|
||||
log.info("Connection established (ConnRef=0x%04x)", f['Msg']['ConnRef'])
|
||||
log.info("Connection established (ConnRef=0x%04x)",
|
||||
f['Msg']['ConnRef'])
|
||||
|
||||
# Read the messages
|
||||
while True:
|
||||
|
@ -195,6 +193,7 @@ class SEDbgMuxApp(cmd2.Cmd):
|
|||
assert rsp == exp
|
||||
break
|
||||
|
||||
|
||||
ap = argparse.ArgumentParser(prog='sedbgmux', description=SEDbgMuxApp.DESC,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
|
||||
|
@ -206,7 +205,8 @@ group.add_argument('--serial-baudrate', metavar='BAUDRATE', type=int, default=11
|
|||
group.add_argument('--serial-timeout', metavar='TIMEOUT', type=int,
|
||||
help='Serial port timeout')
|
||||
|
||||
log.basicConfig(format='[%(levelname)s] %(filename)s:%(lineno)d %(message)s', level=log.INFO)
|
||||
log.basicConfig(
|
||||
format='[%(levelname)s] %(filename)s:%(lineno)d %(message)s', level=log.INFO)
|
||||
|
||||
if __name__ == '__main__':
|
||||
argv = ap.parse_args()
|
||||
|
|
Loading…
Reference in New Issue