Skip to content

Commit

Permalink
Make flashload COM more reliable
Browse files Browse the repository at this point in the history
Fixes for UART RX with IRQ implementation
  • Loading branch information
robamu committed Sep 13, 2024
1 parent cad9683 commit 78dd7ee
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 492 deletions.
37 changes: 25 additions & 12 deletions flashloader/image-loader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env python3
from spacepackets.ecss import RequestId
from spacepackets.ecss.defs import PusService
from spacepackets.ecss.tm import PusTm
import toml
import struct
import logging
import argparse
import threading
import time
import enum
from tmtccmd.com.serial_base import SerialCfg
Expand Down Expand Up @@ -45,6 +43,7 @@

RAW_MEMORY_WRITE_SUBSERVICE = 2
BOOT_NVM_MEMORY_ID = 1
PING_PAYLOAD_SIZE = 0


class ActionId(enum.IntEnum):
Expand Down Expand Up @@ -104,24 +103,38 @@ def main() -> int:
com_if = SerialCobsComIF(serial_cfg)
com_if.open()
file_path = None
if args.target:
if not args.corrupt:
if not args.path:
_LOGGER.error("App Path needs to be specified for the flash process")
return -1
file_path = Path(args.path)
if not file_path.exists():
_LOGGER.error("File does not exist")
return -1
if args.ping:
_LOGGER.info("Sending ping command")
ping_tc = PusTc(
apid=0x00,
service=PusService.S17_TEST,
subservice=1,
seq_count=SEQ_PROVIDER.get_and_increment(),
app_data=bytes(PING_PAYLOAD_SIZE),
)
verificator.add_tc(ping_tc)
com_if.send(ping_tc.pack())

data_available = com_if.data_available(0.4)
if not data_available:
_LOGGER.warning("no ping reply received")
for reply in com_if.receive():
result = verificator.add_tm(
Service1Tm.from_tm(PusTm.unpack(reply, 0), UnpackParams(0))
)
if result is not None and result.completed:
_LOGGER.info("received ping completion reply")
if not args.target:
return 0
if args.target:
if not args.corrupt:
if not args.path:
_LOGGER.error("App Path needs to be specified for the flash process")
return -1
file_path = Path(args.path)
if not file_path.exists():
_LOGGER.error("File does not exist")
return -1
if args.corrupt:
if not args.target:
_LOGGER.error("target for corruption command required")
Expand Down Expand Up @@ -254,7 +267,7 @@ def main() -> int:
):
done = True
# Still keep a small delay
time.sleep(0.01)
# time.sleep(0.05)
verificator.remove_completed_entries()
if done:
break
Expand Down
Loading

0 comments on commit 78dd7ee

Please sign in to comment.