Skip to content

Commit 2299b90

Browse files
committed
[cr] fine tune loggong
1 parent bf31918 commit 2299b90

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/openlaunch/ops243.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
logger = logging.getLogger("ops243")
3333
raw_logger = logging.getLogger("ops243.raw")
3434

35+
# Global flag to control raw reading console output
36+
_show_raw_readings = False
37+
38+
39+
def set_show_raw_readings(enabled: bool):
40+
"""Enable/disable printing raw radar readings to console."""
41+
global _show_raw_readings # pylint: disable=global-statement
42+
_show_raw_readings = enabled
43+
3544

3645
class SpeedUnit(Enum):
3746
"""Speed units supported by OPS243-A."""
@@ -620,7 +629,8 @@ def _parse_reading(self, line: str) -> Optional[SpeedReading]:
620629
direction = Direction.OUTBOUND
621630

622631
# Debug: print raw reading to console (sign indicates direction)
623-
print(f"[RAW] {speed:+.1f} mph -> {direction.value} (mag: {magnitude})")
632+
if _show_raw_readings:
633+
print(f"[RAW] {speed:+.1f} mph -> {direction.value} (mag: {magnitude})")
624634

625635
# Log parsed reading for debugging
626636
logger.debug(f"PARSED: raw_speed={speed:.2f} abs_speed={abs(speed):.2f} dir={direction.value} mag={magnitude}")
@@ -642,7 +652,8 @@ def _parse_reading(self, line: str) -> Optional[SpeedReading]:
642652
direction = Direction.OUTBOUND
643653

644654
# Debug: print raw reading to console
645-
print(f"[RAW] {speed:+.1f} mph -> {direction.value}")
655+
if _show_raw_readings:
656+
print(f"[RAW] {speed:+.1f} mph -> {direction.value}")
646657

647658
logger.debug(f"PARSED (plain): raw_speed={speed:.2f} abs_speed={abs(speed):.2f} dir={direction.value}")
648659

src/openlaunch/server.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from flask_cors import CORS
2121

2222
from .launch_monitor import LaunchMonitor, Shot, ClubType
23-
from .ops243 import SpeedReading, Direction
23+
from .ops243 import SpeedReading, Direction, set_show_raw_readings
2424
from .session_logger import init_session_logger, get_session_logger
2525

2626
# Configure logging
@@ -816,7 +816,8 @@ def main():
816816
"--web-port", type=int, default=8080, help="Web server port (default: 8080)"
817817
)
818818
parser.add_argument("--debug", "-d", action="store_true", help="Enable debug mode")
819-
parser.add_argument("--radar-log", action="store_true", help="Log raw radar data to console")
819+
parser.add_argument("--radar-log", action="store_true", help="Log raw radar data to console (Python logging)")
820+
parser.add_argument("--show-raw", action="store_true", help="Show raw radar readings in console (signed values)")
820821
parser.add_argument(
821822
"--camera", "-c", action="store_true", help="Enable camera for ball detection"
822823
)
@@ -882,6 +883,11 @@ def main():
882883
radar_raw_logger.setLevel(logging.DEBUG)
883884
print("Radar raw logging ENABLED - all readings will be logged")
884885

886+
# Enable raw reading console output if requested
887+
if args.show_raw:
888+
set_show_raw_readings(True)
889+
print("Raw radar readings display ENABLED - signed speed values will be shown")
890+
885891
# Start the monitor
886892
start_monitor(port=args.port, mock=args.mock)
887893

0 commit comments

Comments
 (0)