Timing improvements
* Reduce delays from 200 ms to 100 ms, since 200 ms tends to be too long overall. * Increase pulse interval to 30 ms to avoid the chance of stray pulses after MCU starts sending info packet. * Add 30 ms delay after autoreset cycle to avoid glitches on startup
This commit is contained in:
parent
761c68e469
commit
2d3c24fc3a
@ -198,8 +198,8 @@ class StcBaseProtocol(ABC):
|
||||
raise serial.SerialTimeoutException("pulse timeout")
|
||||
self.ser.write(character)
|
||||
self.ser.flush()
|
||||
time.sleep(0.015)
|
||||
duration += 0.015
|
||||
time.sleep(0.030)
|
||||
duration += 0.030
|
||||
if self.ser.inWaiting() > 0: break
|
||||
|
||||
def initialize_model(self):
|
||||
@ -269,6 +269,7 @@ class StcBaseProtocol(ABC):
|
||||
self.ser.setDTR(True)
|
||||
time.sleep(0.5)
|
||||
self.ser.setDTR(False)
|
||||
time.sleep(0.030)
|
||||
print("done")
|
||||
else:
|
||||
print("Cycling power via shell cmd: " + resetcmd)
|
||||
@ -522,7 +523,7 @@ class Stc89Protocol(StcBaseProtocol):
|
||||
packet += struct.pack(">H", brt)
|
||||
packet += bytes([0xff - (brt >> 8), brt_csum, delay, iap])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
self.ser.baudrate = self.baud_handshake
|
||||
@ -536,7 +537,7 @@ class Stc89Protocol(StcBaseProtocol):
|
||||
packet += struct.pack(">H", brt)
|
||||
packet += bytes([0xff - (brt >> 8), brt_csum, delay])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
if response[0] != 0x8e:
|
||||
@ -712,7 +713,7 @@ class Stc12AProtocol(Stc12AOptionsMixIn, Stc89Protocol):
|
||||
sys.stdout.flush()
|
||||
packet = bytes([0x8f, 0xc0, brt, 0x3f, brt_csum, delay, iap])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
self.ser.baudrate = self.baud_handshake
|
||||
@ -724,7 +725,7 @@ class Stc12AProtocol(Stc12AOptionsMixIn, Stc89Protocol):
|
||||
sys.stdout.flush()
|
||||
packet = bytes([0x8e, 0xc0, brt, 0x3f, brt_csum, delay])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
if response[0] != 0x8e:
|
||||
@ -912,7 +913,7 @@ class Stc12BaseProtocol(StcBaseProtocol):
|
||||
sys.stdout.flush()
|
||||
packet = bytes([0x8f, 0xc0, brt, 0x3f, brt_csum, delay, iap])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
self.ser.baudrate = self.baud_handshake
|
||||
@ -924,7 +925,7 @@ class Stc12BaseProtocol(StcBaseProtocol):
|
||||
sys.stdout.flush()
|
||||
packet = bytes([0x8e, 0xc0, brt, 0x3f, brt_csum, delay])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
if response[0] != 0x84:
|
||||
@ -1206,7 +1207,7 @@ class Stc15AProtocol(Stc12Protocol):
|
||||
packet += struct.pack(">B", 230400 // self.baud_transfer)
|
||||
packet += bytes([0xa1, 0x64, 0xb8, 0x00, iap_wait, 0x20, 0xff, 0x00])
|
||||
self.write_packet(packet)
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
self.ser.baudrate = self.baud_transfer
|
||||
response = self.read_packet()
|
||||
if response[0] != 0x84:
|
||||
|
Loading…
Reference in New Issue
Block a user