Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ fprime-venv: uv ## Create a virtual environment
@INST_CFG=$$(ls $(shell pwd)/fprime-venv/lib/python*/site-packages/fprime_yamcs/yamcs/src/main/yamcs/etc/yamcs.fprime-project.yaml 2>/dev/null | head -1); \
if [ -z "$$INST_CFG" ]; then echo "⚠ instance config not found, skipping"; exit 0; fi; \
$(VIRTUAL_ENV)/bin/python tools/apply-yamcs-instance-config-fix.py "$$INST_CFG"
@echo "Applying fprime-yamcs-events opcode-ack fix..."
@EVENTS_PROC=$$(ls $(shell pwd)/fprime-venv/lib/python*/site-packages/fprime_yamcs/events/processor.py 2>/dev/null | head -1); \
if [ -z "$$EVENTS_PROC" ]; then echo "⚠ events processor not found, skipping"; exit 0; fi; \
$(VIRTUAL_ENV)/bin/python tools/apply-opcode-ack-fix.py "$$EVENTS_PROC"
Comment on lines +50 to +53

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fork instead. Thoughts?



.PHONY: zephyr-setup
Expand Down Expand Up @@ -307,6 +311,7 @@ yamcs-stop: ## Stop all YAMCS-related processes (YAMCS server, events bridge, ad
}; \
kill_udp_port 50001 'serial adapter'; \
kill_udp_port 50000 'TM UDP sender'; \
stop_repo_processes 'opcode_ack_bridge.py' 'opcode-ack bridge'; \
stop_repo_processes 'fprime-yamcs-events' 'fprime-yamcs-events'; \
stop_repo_processes 'fprime_yamcs' 'fprime-yamcs wrapper'; \
stop_repo_processes 'mvn' 'Maven yamcs runner'; \
Expand Down Expand Up @@ -337,6 +342,8 @@ yamcs: fprime-venv yamcs-dict ## Run YAMCS with serial adapter (Use Case 1: UART
@sleep 5
@echo "Starting fprime-yamcs-events bridge..."
$(UV_RUN) fprime-yamcs-events --dictionary $(shell pwd)/build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json &
@echo "Starting OpCode acknowledgement bridge..."
$(VIRTUAL_ENV)/bin/python tools/yamcs/opcode_ack_bridge.py --dictionary $(shell pwd)/build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json &
@echo "Starting serial adapter on $(UART_DEVICE)..."
$(VIRTUAL_ENV)/bin/python tools/yamcs/proves_adapter.py \
--mode serial \
Expand Down
58 changes: 58 additions & 0 deletions tools/apply-opcode-ack-fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Patch FPrimeEventProcessor to include event args in the send_event extra field.

The extra field is a free-form str→str mapping that YAMCS stores alongside each
event. By including event arguments there, the opcode_ack_bridge can recover the
opcode value from OpCodeCompleted events without needing to re-decode the raw
CCSDS packet or parse the human-readable message string.
"""

import sys

if len(sys.argv) != 2:
print(
f"Usage: {sys.argv[0]} <path-to-processor.py>",
file=sys.stderr,
)
sys.exit(1)

path = sys.argv[1]
with open(path) as f:
content = f.read()

SENTINEL = "extra=event_args if event_args else None,"

if SENTINEL in content:
print("⚠ fprime-yamcs-events opcode-ack fix already applied")
sys.exit(0)

OLD = (
" self.yamcs_client.send_event(\n"
" instance=self.yamcs_instance,\n"
" source='FPrimeEventProcessor',\n"
" event_type=event_name,\n"
" severity=yamcs_severity,\n"
" message=message,\n"
" )\n"
)
NEW = (
" self.yamcs_client.send_event(\n"
" instance=self.yamcs_instance,\n"
" source='FPrimeEventProcessor',\n"
" event_type=event_name,\n"
" severity=yamcs_severity,\n"
" message=message,\n"
" extra=event_args if event_args else None,\n"
" )\n"
)

fixed = content.replace(OLD, NEW)

if fixed == content:
print(
"❌ Error: pattern not found in events processor — fix may not apply or upstream changed"
)
sys.exit(1)

with open(path, "w") as f:
f.write(fixed)
print("✓ Applied fprime-yamcs-events opcode-ack fix")
Loading
Loading