mirror of
https://github.com/furrtek/PrecIR.git
synced 2026-03-30 14:15:52 +00:00
Better PP16 timings
Coin cell charge detection bugfix ESL Blaster FW version detection Updated flashtest.py to write nasty frames (DM show debug info permanently)
This commit is contained in:
@@ -8,15 +8,15 @@ import sys
|
||||
import serial
|
||||
|
||||
# Search for connected ESL Blaster
|
||||
blaster_port = tx.search_esl_blaster()
|
||||
if (blaster_port == "0"):
|
||||
blaster_info = tx.search_esl_blaster()
|
||||
if (blaster_info[0] == "0"):
|
||||
exit()
|
||||
|
||||
ser = serial.Serial(blaster_port, 57600, timeout = 5) # 5s timeout for read
|
||||
ser = serial.Serial(blaster_info[0], 57600, timeout = 5) # 5s timeout for read
|
||||
ser.reset_input_buffer()
|
||||
|
||||
frameA = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xAB, 0x09, 0x00, 0x00, 0xF2, 0xA7] # Segment change page
|
||||
frameB = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00, 0x06, 0x11, 0x00, 0x00, 0xEA, 0x80] # DM change page
|
||||
frameB = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0D, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF1, 0x00, 0x00, 0x00, 0x0A, 0x5D, 0x14] # DM show debug infos
|
||||
|
||||
data = []
|
||||
data.extend([0] * (1024 - len(data)))
|
||||
@@ -29,7 +29,7 @@ data[2+72:2+72+len(frameB)] = frameB
|
||||
print(len(data))
|
||||
|
||||
ba = bytearray()
|
||||
ba.append('W')
|
||||
ba.append(87) # W:Write flash
|
||||
ser.write(ba)
|
||||
ser.flush()
|
||||
for p in range(0, 8):
|
||||
@@ -39,7 +39,7 @@ for p in range(0, 8):
|
||||
|
||||
ser.write(ba)
|
||||
ser.flush()
|
||||
ser.read_until('K')
|
||||
ser.read_until(b'K')
|
||||
print("OK")
|
||||
|
||||
print(ser.read())
|
||||
|
||||
@@ -25,8 +25,8 @@ port = sys.argv[1]
|
||||
|
||||
# Search for connected ESL Blaster if required
|
||||
if (port == "0"):
|
||||
blaster_port = tx.search_esl_blaster()
|
||||
if (blaster_port == "0"):
|
||||
blaster_info = tx.search_esl_blaster()
|
||||
if (blaster_info[0] == "0"):
|
||||
exit()
|
||||
|
||||
# Get PLID from barcode string
|
||||
@@ -38,7 +38,7 @@ frames = []
|
||||
|
||||
frame = pr.make_raw_frame(0x85 if (sys.argv[3] == "DM") else 0x84, PLID, ba[0])
|
||||
frame.extend(ba[1:])
|
||||
pr.terminate_frame(frame, int(sys.argv[5]))
|
||||
pr.terminate_frame(frame, 0, int(sys.argv[5]))
|
||||
frames.append(frame)
|
||||
|
||||
# DEBUG
|
||||
@@ -50,7 +50,7 @@ for fr in frames:
|
||||
|
||||
# Send data to IR transmitter
|
||||
if (port == "0"):
|
||||
tx.transmit_esl_blaster(frames, blaster_port)
|
||||
tx.transmit_esl_blaster(frames, 0, blaster_info[0])
|
||||
else:
|
||||
tx.transmit_serial(frames, port)
|
||||
print("Done.")
|
||||
|
||||
@@ -5,43 +5,50 @@
|
||||
import serial
|
||||
|
||||
def try_serialport(comport):
|
||||
try:
|
||||
ser = serial.Serial(comport, 57600, timeout = 1) # 1s timeout for read
|
||||
ser.write("?".encode())
|
||||
ser.flush()
|
||||
test = ser.read_until("ESLBlaster")
|
||||
ser.close()
|
||||
if (len(test) >= 10):
|
||||
print("Found ESL Blaster on " + comport)
|
||||
return True
|
||||
else:
|
||||
print("Timeout on " + comport)
|
||||
return False
|
||||
except serial.SerialException:
|
||||
#print("SerialException on " + comport) # Debug
|
||||
return False
|
||||
try:
|
||||
ser = serial.Serial(comport, 57600, timeout = 1) # 1s timeout for read
|
||||
ser.write("?".encode())
|
||||
ser.flush()
|
||||
test = ser.read_until("ESLBlaster")
|
||||
ser.close()
|
||||
if (len(test) >= 12):
|
||||
hw_ver = chr(test[10])
|
||||
fw_ver = int(chr(test[11]))
|
||||
print("Found ESL Blaster (HW %s, FW V%d) on %s" % (hw_ver, fw_ver, comport))
|
||||
return [True, hw_ver, fw_ver]
|
||||
else:
|
||||
print("Timeout on " + comport)
|
||||
return [False, 0, 0]
|
||||
except serial.SerialException:
|
||||
#print("SerialException on " + comport) # Debug
|
||||
return [False, 0, 0]
|
||||
|
||||
def search_esl_blaster():
|
||||
found = False
|
||||
|
||||
# Windows
|
||||
for n in range(1, 10):
|
||||
comport = "COM" + str(n)
|
||||
if try_serialport(comport):
|
||||
result = try_serialport(comport)
|
||||
if result[0]:
|
||||
found = True
|
||||
break
|
||||
|
||||
# Linux
|
||||
if found == False:
|
||||
for n in range(1, 10):
|
||||
comport = "/dev/ttyACM" + str(n)
|
||||
if try_serialport(comport):
|
||||
result = try_serialport(comport)
|
||||
if result[0]:
|
||||
found = True
|
||||
break
|
||||
|
||||
if found == False:
|
||||
print("Could not find ESL Blaster.")
|
||||
return "0"
|
||||
else:
|
||||
return comport
|
||||
result[0] = comport
|
||||
|
||||
return result
|
||||
|
||||
def transmit_serial(frames, port):
|
||||
ser = serial.Serial(port, 57600, timeout = 10) # 10s timeout for read
|
||||
@@ -68,7 +75,7 @@ def transmit_serial(frames, port):
|
||||
|
||||
ser.close()
|
||||
|
||||
def transmit_esl_blaster(frames, port):
|
||||
def transmit_esl_blaster(frames, pp16, port):
|
||||
ser = serial.Serial(port, 57600, timeout = 10) # 10s timeout for read
|
||||
ser.reset_input_buffer()
|
||||
frame_count = len(frames)
|
||||
@@ -80,7 +87,14 @@ def transmit_esl_blaster(frames, port):
|
||||
for fr in frames:
|
||||
data_size = len(fr) - 2
|
||||
repeats = fr[-2] + (fr[-1] * 256)
|
||||
print("Transmitting frame %u/%u, length %u, repeated %u times." % (i, frame_count, data_size, repeats))
|
||||
|
||||
if repeats > 32767: # Cap to 15 bits because FW V2 uses bit 16 to indicate PP16 protocol
|
||||
repeats = 32767
|
||||
|
||||
print("Transmitting frame %u/%u using %s, length %u, repeated %u times." % (i, frame_count, "PP16" if pp16 else "PP4", data_size, repeats))
|
||||
|
||||
if pp16:
|
||||
repeats |= 0x8000
|
||||
|
||||
ba = bytearray()
|
||||
ba.append(76) # L:Load
|
||||
|
||||
Reference in New Issue
Block a user