Revert "Add "stc89a" protocol"

This reverts commit c5d509d1fa.
This commit is contained in:
Grigori Goronzy 2021-01-03 18:36:05 +01:00
parent d708a00e9e
commit 1ec855e6a1
2 changed files with 1 additions and 26 deletions

View File

@ -26,7 +26,6 @@ import stcgal
import serial import serial
from stcgal.utils import BaudType from stcgal.utils import BaudType
from stcgal.protocols import Stc89Protocol from stcgal.protocols import Stc89Protocol
from stcgal.protocols import Stc89AProtocol
from stcgal.protocols import Stc12AProtocol from stcgal.protocols import Stc12AProtocol
from stcgal.protocols import Stc12BProtocol from stcgal.protocols import Stc12BProtocol
from stcgal.protocols import Stc12Protocol from stcgal.protocols import Stc12Protocol
@ -50,8 +49,6 @@ class StcGal:
"""Initialize protocol backend""" """Initialize protocol backend"""
if opts.protocol == "stc89": if opts.protocol == "stc89":
self.protocol = Stc89Protocol(opts.port, opts.handshake, opts.baud) self.protocol = Stc89Protocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc89a":
self.protocol = Stc89AProtocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc12a": elif opts.protocol == "stc12a":
self.protocol = Stc12AProtocol(opts.port, opts.handshake, opts.baud) self.protocol = Stc12AProtocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc12b": elif opts.protocol == "stc12b":
@ -231,7 +228,7 @@ def cli():
parser.add_argument("-a", "--autoreset", help="cycle power automatically by asserting DTR", action="store_true") parser.add_argument("-a", "--autoreset", help="cycle power automatically by asserting DTR", action="store_true")
parser.add_argument("-r", "--resetcmd", help="shell command for board power-cycling (instead of DTR assertion)", action="store") parser.add_argument("-r", "--resetcmd", help="shell command for board power-cycling (instead of DTR assertion)", action="store")
parser.add_argument("-P", "--protocol", help="protocol version (default: auto)", parser.add_argument("-P", "--protocol", help="protocol version (default: auto)",
choices=["stc89", "stc89a", "stc12a", "stc12b", "stc12", "stc15a", "stc15", "stc8", "usb15", "auto"], default="auto") choices=["stc89", "stc12a", "stc12b", "stc12", "stc15a", "stc15", "stc8", "usb15", "auto"], default="auto")
parser.add_argument("-p", "--port", help="serial port device", default="/dev/ttyUSB0") parser.add_argument("-p", "--port", help="serial port device", default="/dev/ttyUSB0")
parser.add_argument("-b", "--baud", help="transfer baud rate (default: 19200)", type=BaudType(), default=19200) parser.add_argument("-b", "--baud", help="transfer baud rate (default: 19200)", type=BaudType(), default=19200)
parser.add_argument("-l", "--handshake", help="handshake baud rate (default: 2400)", type=BaudType(), default=2400) parser.add_argument("-l", "--handshake", help="handshake baud rate (default: 2400)", type=BaudType(), default=2400)

View File

@ -225,8 +225,6 @@ class StcBaseProtocol(ABC):
mcu_name += "E" if self.status_packet[17] < 0x70 else "W" mcu_name += "E" if self.status_packet[17] < 0x70 else "W"
self.model = self.model._replace(name = mcu_name) self.model = self.model._replace(name = mcu_name)
self.bsl_version = self.status_packet[17]
def get_status_packet(self): def get_status_packet(self):
"""Read and decode status packet""" """Read and decode status packet"""
@ -385,10 +383,6 @@ class StcAutoProtocol(StcBaseProtocol):
else: else:
self.protocol_name = None self.protocol_name = None
# STC89 devices with BSL version 7.x.x have a slightly different protocol
if self.protocol_name == "stc89" and self.bsl_version >= 0x70:
self.protocol_name = "stc89a"
def initialize_options(self, status_packet): def initialize_options(self, status_packet):
raise NotImplementedError raise NotImplementedError
@ -613,22 +607,6 @@ class Stc89Protocol(StcBaseProtocol):
print("done") print("done")
class Stc89AProtocol(Stc89Protocol):
"""STC89 protocol variant with different framing"""
def extract_payload(self, packet):
"""Verify the checksum of packet and return its payload"""
packet_csum, = struct.unpack(">H", packet[-3:-1])
calc_csum = sum(packet[2:-3]) & 0xffff
if packet_csum != calc_csum:
self.dump_packet(packet)
raise StcFramingException("packet checksum mismatch")
payload = StcBaseProtocol.extract_payload(self, packet)
return payload[:-3]
class Stc12AOptionsMixIn: class Stc12AOptionsMixIn:
def program_options(self): def program_options(self):
print("Setting options: ", end="") print("Setting options: ", end="")