Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
targets: ${{ steps.set-targets.outputs.targets }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- id: set-targets
run: echo "targets=[$(grep -r "\[env:" targets | sed 's/.*://' | sed s/.$// | egrep "UART" | tr '\n' ',' | sed 's/,$/"\n/' | sed 's/,/","/'g | sed 's/^/"/')]" >> $GITHUB_OUTPUT

Expand All @@ -24,15 +24,15 @@ jobs:
uses: rlespinasse/github-slug-action@v4

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.target }}
Expand All @@ -44,7 +44,7 @@ jobs:
pip install wheel

- name: Cache PlatformIO
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio
Expand All @@ -59,7 +59,7 @@ jobs:
cp -r hardware ~/artifacts/firmware

- name: Store Artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: temp-${{ matrix.target }}
path: |
Expand All @@ -72,17 +72,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.10'

- name: Get firmware artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
Expand All @@ -94,7 +94,7 @@ jobs:
shiv -c flash -o ../dist/firmware/flasher.pyz pyserial .

- name: Update firmware artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: firmware
path: dist/**/*
Expand Down
8 changes: 4 additions & 4 deletions lib/WIFI/devWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void startWiFi(unsigned long now)
connectionState = wifiUpdate;
}

INFOLN("Begin Webupdater");
DBGLN("Begin Webupdater");

WiFi.persistent(false);
WiFi.disconnect();
Expand All @@ -667,7 +667,7 @@ static void startWiFi(unsigned long now)
changeTime = now;
changeMode = WIFI_STA;
}
laststatus = WL_DISCONNECTED;
laststatus = WL_NO_SHIELD;
wifiStarted = true;
}

Expand Down Expand Up @@ -823,7 +823,7 @@ static void HandleWebUpdate()
changeMode = WIFI_AP;
DBGLN("Connection failed %d", status);
}
if (changeMode != wifiMode && changeMode != WIFI_OFF && (now - changeTime) > 500) {
if (changeMode != wifiMode && changeMode != WIFI_OFF) {
switch(changeMode) {
case WIFI_AP:
DBGLN("Changing to AP mode");
Expand Down Expand Up @@ -1021,7 +1021,7 @@ static int timeout()
}

device_t WIFI_device = {
.initialize = wifiOff,
.initialize = nullptr,
.start = start,
.event = event,
.timeout = timeout
Expand Down
93 changes: 85 additions & 8 deletions python/osd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ def crc8_dvb_s2(crc, a):
crc = crc << 1
return crc & 0xFF

def format_bytes(data):
return " ".join(f"{b:02X}" for b in data)

def send_msp(s, body):
crc = 0
for x in body:
crc = crc8_dvb_s2(crc, x)
msp = [ord('$'),ord('X'),ord('<')]
msp = msp + body
msp.append(crc)
msp = bytes([ord('$'), ord('X'), ord('<')] + body + [crc])
s.write(msp)
print('Sending ' + str(msp))
print("Sending " + format_bytes(msp))

def send_clear(s):
msp = [0,0xb6,0x00,1,0,0x02]
Expand All @@ -46,10 +47,86 @@ def send_msg(s, row, col, str):
msp.append(ord(x))
send_msp(s, msp)

class MspReader:
def __init__(self):
self.buffer = bytearray()
self.text_buffer = bytearray()

def _flush_text(self, chunk):
events = []
if not chunk:
return events
self.text_buffer.extend(chunk)
while True:
newline_pos = -1
for marker in (b"\n", b"\r"):
pos = self.text_buffer.find(marker)
if pos != -1 and (newline_pos == -1 or pos < newline_pos):
newline_pos = pos
if newline_pos == -1:
break
line = bytes(self.text_buffer[:newline_pos]).decode("utf-8", errors="replace").strip()
del self.text_buffer[:newline_pos + 1]
if line:
events.append(("text", line))
return events

def feed(self, data):
self.buffer.extend(data)
events = []
while True:
start = self.buffer.find(b"$X")
if start < 0:
events.extend(self._flush_text(self.buffer))
self.buffer.clear()
break
if start > 0:
events.extend(self._flush_text(self.buffer[:start]))
del self.buffer[:start]
if len(self.buffer) < 9:
break
direction = self.buffer[2]
if direction not in (ord("<"), ord(">"), ord("!")):
events.extend(self._flush_text(self.buffer[:1]))
del self.buffer[0]
continue
payload_size = self.buffer[6] | (self.buffer[7] << 8)
frame_size = 9 + payload_size
if len(self.buffer) < frame_size:
break
frame = bytes(self.buffer[:frame_size])
del self.buffer[:frame_size]
body = frame[3:-1]
expected_crc = frame[-1]
crc = 0
for value in body:
crc = crc8_dvb_s2(crc, value)
events.append(("packet", frame, crc == expected_crc))
return events

def describe_packet(frame, crc_valid):
direction = chr(frame[2])
function = frame[5] << 8 | frame[4]
payload_size = frame[6] | (frame[7] << 8)
payload = frame[8:8 + payload_size]
status = "OK" if crc_valid else "BAD CRC"
prefix = f"Received {direction} 0x{function:04X} [{status}]"
if payload:
return f"{prefix}: {format_bytes(payload)}"
return prefix

def thread_function(s: serial.Serial):
reader = MspReader()
while True:
b = s.readall()
if len(b): print(b)
data = s.read(s.in_waiting or 1)
if not data:
continue
for event in reader.feed(data):
if event[0] == "text":
print(f"Serial log: {event[1]}")
else:
_, frame, crc_valid = event
print(describe_packet(frame, crc_valid))

def short_help():
print("Command should be one of:")
Expand All @@ -60,7 +137,7 @@ def short_help():

def help():
print()
print("Depending on the OSD font only UPPERCASE letters ay display as actual letters,")
print("Depending on the OSD font only UPPERCASE letters may display as actual letters,")
print("this is because the other character positions are used to display other symbols on the OSD.")
short_help()
print()
Expand All @@ -82,7 +159,7 @@ def help():
args.port = serials_find.get_serial_port()

s = serial.Serial(port=args.port, baudrate=args.baud, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=0, rtscts=0)
threading.Thread(target=thread_function, args=(s,)).start()
threading.Thread(target=thread_function, args=(s,), daemon=True).start()

help()
for line in sys.stdin:
Expand Down
Loading