Skip to content

Commit d724a8d

Browse files
author
Radar Distance Monitor
committed
Add multi-host support with chip detection and improved logging
Features added: - Support for 1 to many hosts (flexible configuration) - New HOSTS list format alongside backward-compatible legacy format - Automatic radar chip detection and display (model + ID) - Flexible command-line arguments (--host, --user, --password, --command, --tag) - Clean logging (no false error messages for initialization output) - Enhanced legend with chip information - Updated examples for single and multiple host configurations Breaking changes: None (fully backward compatible) Configuration: Both legacy (HOST1_CONFIG/HOST2_CONFIG) and new (HOSTS list) formats supported CLI: Both legacy (--host1, --user1, etc.) and new (--host, --user, etc.) arguments supported
1 parent 6a883b3 commit d724a8d

File tree

6 files changed

+318
-94
lines changed

6 files changed

+318
-94
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Radar Distance Monitor
22

3-
A Python application that connects to two SSH hosts, runs distance measurement commands, and displays real-time distance data in a graph.
3+
A Python application that connects to one or more SSH hosts, runs distance measurement commands, and displays real-time distance data in a graph.
44

55
## Quick Start
66

config/config_example.py

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,69 @@
22
"""
33
Example configuration file for radar distance monitoring.
44
Copy this file to config.py and modify the values for your setup.
5+
6+
Two configuration formats are supported:
7+
8+
1. New HOSTS format (recommended) - supports any number of hosts:
9+
Use the HOSTS list below for flexible configuration.
10+
11+
2. Legacy format (backward compatible) - supports exactly 1 or 2 hosts:
12+
Use HOST1_CONFIG and HOST2_CONFIG (commented out below).
13+
14+
Choose ONE format - do not use both at the same time.
515
"""
616

7-
# SSH connection settings for Host 1
8-
HOST1_CONFIG = {
9-
'host': '192.168.0.58', # IP address or hostname
10-
'username': 'fio', # SSH username
11-
'password': 'fio', # SSH password (consider using SSH keys instead)
12-
'command': 'sudo RADAR_DEBUG=1 seamless_dev_spi spi.mode="presence"', # Command to run on the host
13-
'tag': 'Sentai', # Display name for this host on the chart
14-
}
17+
# ============================================================================
18+
# NEW FORMAT (Recommended): HOSTS list - supports 1 to many hosts
19+
# ============================================================================
1520

16-
# SSH connection settings for Host 2
17-
HOST2_CONFIG = {
18-
'host': '192.168.0.96', # IP address or hostname
19-
'username': 'rpi', # SSH username
20-
'password': 'infineon', # SSH password (consider using SSH keys instead)
21-
'command': 'sudo RADAR_DEBUG=1 RADAR_SPI_SPEED=12000000 ./seamless_dev_spi spi.mode="presence"', # Command to run on the host
22-
'tag': 'Raspberry Pi', # Display name for this host on the chart
23-
}
21+
HOSTS = [
22+
{
23+
'host': '192.168.0.58', # IP address or hostname
24+
'username': 'fio', # SSH username
25+
'password': 'fio', # SSH password (consider using SSH keys instead)
26+
'command': 'sudo RADAR_DEBUG=1 seamless_dev_spi spi.mode="presence"', # Command to run on the host
27+
'tag': 'Sentai', # Display name for this host on the chart
28+
},
29+
{
30+
'host': '192.168.0.96', # IP address or hostname
31+
'username': 'rpi', # SSH username
32+
'password': 'infineon', # SSH password (consider using SSH keys instead)
33+
'command': 'sudo RADAR_DEBUG=1 RADAR_SPI_SPEED=12000000 ./seamless_dev_spi spi.mode="presence"', # Command to run on the host
34+
'tag': 'Raspberry Pi', # Display name for this host on the chart
35+
},
36+
# Add more hosts as needed:
37+
# {
38+
# 'host': '192.168.0.100',
39+
# 'username': 'sensor',
40+
# 'password': 'password123',
41+
# 'command': 'sensor_command',
42+
# 'tag': 'Sensor 3',
43+
# },
44+
]
45+
46+
# ============================================================================
47+
# LEGACY FORMAT (Backward Compatible): Individual host configs
48+
# ============================================================================
49+
# Comment out the HOSTS list above and uncomment the configs below to use legacy format
50+
51+
# # SSH connection settings for Host 1
52+
# HOST1_CONFIG = {
53+
# 'host': '192.168.0.58', # IP address or hostname
54+
# 'username': 'fio', # SSH username
55+
# 'password': 'fio', # SSH password (consider using SSH keys instead)
56+
# 'command': 'sudo RADAR_DEBUG=1 seamless_dev_spi spi.mode="presence"', # Command to run on the host
57+
# 'tag': 'Sentai', # Display name for this host on the chart
58+
# }
59+
60+
# # SSH connection settings for Host 2 (optional - can be omitted for single host)
61+
# HOST2_CONFIG = {
62+
# 'host': '192.168.0.96', # IP address or hostname
63+
# 'username': 'rpi', # SSH username
64+
# 'password': 'infineon', # SSH password (consider using SSH keys instead)
65+
# 'command': 'sudo RADAR_DEBUG=1 RADAR_SPI_SPEED=12000000 ./seamless_dev_spi spi.mode="presence"', # Command to run on the host
66+
# 'tag': 'Raspberry Pi', # Display name for this host on the chart
67+
# }
2468

2569
# Graph settings
2670
GRAPH_CONFIG = {

examples/advanced_config.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
#!/usr/bin/env python3
22
"""
33
Advanced configuration example for radar distance monitoring.
4-
This example shows advanced settings for production monitoring setup.
4+
This example shows advanced settings for production monitoring setup with multiple sensors.
55
"""
66

7-
# SSH connection settings for Host 1 - Production sensor array
8-
HOST1_CONFIG = {
9-
'host': '192.168.10.100', # Production sensor IP
10-
'username': 'sensor_monitor', # Dedicated monitoring user
11-
'password': 'SecurePassword123', # Strong password
12-
'command': '/opt/radar/bin/distance_sensor --json --continuous',
13-
'tag': 'Production Line A', # Descriptive name
14-
}
15-
16-
# SSH connection settings for Host 2 - Backup sensor array
17-
HOST2_CONFIG = {
18-
'host': '192.168.10.101', # Backup sensor IP
19-
'username': 'sensor_monitor', # Same monitoring user
20-
'password': 'SecurePassword123', # Same strong password
21-
'command': '/opt/radar/bin/distance_sensor --json --continuous',
22-
'tag': 'Production Line B', # Descriptive name
23-
}
7+
# Multiple hosts configuration using new HOSTS format
8+
HOSTS = [
9+
{
10+
'host': '192.168.10.100', # Production sensor IP
11+
'username': 'sensor_monitor', # Dedicated monitoring user
12+
'password': 'SecurePassword123', # Strong password
13+
'command': '/opt/radar/bin/distance_sensor --json --continuous',
14+
'tag': 'Production Line A', # Descriptive name
15+
},
16+
{
17+
'host': '192.168.10.101', # Backup sensor IP
18+
'username': 'sensor_monitor', # Same monitoring user
19+
'password': 'SecurePassword123', # Same strong password
20+
'command': '/opt/radar/bin/distance_sensor --json --continuous',
21+
'tag': 'Production Line B', # Descriptive name
22+
},
23+
{
24+
'host': '192.168.10.102', # Additional sensor
25+
'username': 'sensor_monitor', # Same monitoring user
26+
'password': 'SecurePassword123', # Same strong password
27+
'command': '/opt/radar/bin/distance_sensor --json --continuous',
28+
'tag': 'Quality Control', # Descriptive name
29+
},
30+
{
31+
'host': '192.168.10.103', # Additional sensor
32+
'username': 'sensor_monitor', # Same monitoring user
33+
'password': 'SecurePassword123', # Same strong password
34+
'command': '/opt/radar/bin/distance_sensor --json --continuous',
35+
'tag': 'Package Detection', # Descriptive name
36+
},
37+
]
2438

2539
# Advanced graph settings for production monitoring
2640
GRAPH_CONFIG = {

examples/simple_config.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
#!/usr/bin/env python3
22
"""
33
Simple configuration example for radar distance monitoring.
4-
This example shows a basic setup for monitoring two radar sensors.
4+
This example shows a basic setup for monitoring a single radar sensor.
55
"""
66

7-
# SSH connection settings for Host 1 - Front entrance sensor
8-
HOST1_CONFIG = {
9-
'host': 'sensor1.local', # Replace with your sensor host
10-
'username': 'admin', # Replace with your username
11-
'password': 'your_password', # Replace with your password
12-
'command': 'radar_distance', # Replace with your radar command
13-
'tag': 'Front Entrance', # Friendly name for the chart
14-
}
7+
# Single host configuration using new HOSTS format
8+
HOSTS = [
9+
{
10+
'host': 'sensor1.local', # Replace with your sensor host
11+
'username': 'admin', # Replace with your username
12+
'password': 'your_password', # Replace with your password
13+
'command': 'radar_distance', # Replace with your radar command
14+
'tag': 'Front Entrance', # Friendly name for the chart
15+
},
16+
]
1517

16-
# SSH connection settings for Host 2 - Back entrance sensor
17-
HOST2_CONFIG = {
18-
'host': 'sensor2.local', # Replace with your sensor host
19-
'username': 'admin', # Replace with your username
20-
'password': 'your_password', # Replace with your password
21-
'command': 'radar_distance', # Replace with your radar command
22-
'tag': 'Back Entrance', # Friendly name for the chart
23-
}
18+
# For multiple hosts, just add more entries:
19+
# HOSTS = [
20+
# {
21+
# 'host': 'sensor1.local',
22+
# 'username': 'admin',
23+
# 'password': 'your_password',
24+
# 'command': 'radar_distance',
25+
# 'tag': 'Front Entrance',
26+
# },
27+
# {
28+
# 'host': 'sensor2.local',
29+
# 'username': 'admin',
30+
# 'password': 'your_password',
31+
# 'command': 'radar_distance',
32+
# 'tag': 'Back Entrance',
33+
# },
34+
# ]
2435

2536
# Graph settings
2637
GRAPH_CONFIG = {

examples/single_host_config.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Single host configuration example for radar distance monitoring.
4+
This example shows how to configure monitoring for just one radar sensor.
5+
"""
6+
7+
# Single host configuration using new HOSTS format
8+
HOSTS = [
9+
{
10+
'host': '192.168.1.100', # Replace with your sensor host IP
11+
'username': 'pi', # Replace with your username
12+
'password': 'raspberry', # Replace with your password
13+
'command': 'sudo radar_sensor --mode presence', # Replace with your radar command
14+
'tag': 'Main Sensor', # Friendly name for the chart
15+
},
16+
]
17+
18+
# Graph settings optimized for single sensor monitoring
19+
GRAPH_CONFIG = {
20+
'max_points': 200, # Show more history for single sensor
21+
'update_interval': 100, # Update every 100ms
22+
'window_size': (10, 6), # Suitable window size for single sensor
23+
}
24+
25+
# Logging settings
26+
LOG_LEVEL = 'INFO' # Show informational messages

0 commit comments

Comments
 (0)