Skip to content
Open
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
2 changes: 1 addition & 1 deletion connections/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import namedtuple
from typing import Callable

ConnectionMessage = namedtuple('ConnectionMessage', ['device_address', 'connection', 'data'])
ConnectionMessage = namedtuple('ConnectionMessage', ['device_address', 'connection', 'data','signal_strength'])


class Connection(ABC):
Expand Down
11 changes: 6 additions & 5 deletions connections/debug/debug_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ def _run(self) -> None:
# full_arr.extend(self.bad_subpacket_id_mock()) # bad id, to see handling of itself and remaining data
full_arr.extend(self.gps_mock_random())
full_arr.extend(self.orientation_mock_random())
self.receive(full_arr)
signal_strength = random.uniform(0,255)
self.receive(full_arr,signal_strength)

LOGGER.warning(f"Debug connection thread shut down (device_address={self.device_address})")

def receive(self, data):
def receive(self, data, signal_strength):
with self.lock:

if not self.callback:
raise Exception("Can't receive data. Callback not set.")

message = ConnectionMessage(device_address=self.device_address, connection=self, data=data)
message = ConnectionMessage(device_address=self.device_address, connection=self, data=data, signal_strength=signal_strength)

self.callback(message)

Expand Down Expand Up @@ -196,9 +197,9 @@ def broadcast(self, data) -> None: # must be thead safe
elif data == bytes([0x44]):
DISARMED_EVENT.increment()
elif data == bytes([0x50]):
self.receive(self.status_ping_mock_set_values())
self.receive(self.status_ping_mock_set_values(),25) #TODO: FIX THIS 25 SHOUDL BE STRENGTH
elif data == bytes([0x43]):
self.receive(self.config_mock_set_values())
self.receive(self.config_mock_set_values(),25)

def shutdown(self) -> None:
if not self.connectionThread.is_alive():
Expand Down
5 changes: 4 additions & 1 deletion connections/serial/serial_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def _newData(self, xbee_message):
message = ConnectionMessage(
device_address=str(xbee_message.remote_device.get_64bit_addr()),
connection=self,
data=xbee_message.data)
data=xbee_message.data,
signal_strength = int(self.device.get_parameter("DB"),16))

@vanquon vanquon Mar 14, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to test if this line gets the signal strength correctly.

#seems like you can get signal strength value (hex) through DB parameter
#https://www.digi.com/resources/documentation/Digidocs/90001456-13/concepts/c_rssi_pin_and_signal_strength.htm

self.callback(message)

Expand Down
2 changes: 2 additions & 0 deletions main_window/data_entry_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class DataEntryIds(Enum):
ACCELEROMETER = auto()
IMU = auto()

SIGNAL_STRENGTH = auto()

# Status
OVERALL_STATUS = auto()
DROGUE_IGNITER_CONTINUITY = auto()
Expand Down
2 changes: 2 additions & 0 deletions main_window/read_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def run(self):
full_address = FullAddress(connection_name=self.connection_to_name[connection],
device_address=connection_message.device_address)
data = connection_message.data
signal_strength = connection_message.signal_strength

byte_stream: BytesIO = BytesIO(data)

Expand All @@ -91,6 +92,7 @@ def run(self):
try:
self.packet_parser.set_endianness(connection.isIntBigEndian(), connection.isFloatBigEndian())
parsed_data: Dict[DataEntryIds, any] = self.packet_parser.extract(byte_stream)
parsed_data[DataEntryIds.SIGNAL_STRENGTH] = signal_strength

if DataEntryIds.DEVICE_TYPE in parsed_data and DataEntryIds.VERSION_ID in parsed_data:
self.device_manager.register_device(parsed_data[DataEntryIds.DEVICE_TYPE], parsed_data[DataEntryIds.VERSION_ID], full_address)
Expand Down
6 changes: 6 additions & 0 deletions profiles/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def update_acceleration(rocket_data: RocketData, device: DeviceType) -> str:
else:
return VALUE_NOT_AVAILABLE

def update_signal_strength(rocket_data: RocketData, device: DeviceType) -> str:
sig_strength = rocket_data.last_value_by_device(device, DataEntryIds.SIGNAL_STRENGTH)
if sig_strength is not None:
return f'{sig_strength:.2f} -dBm'
else:
return VALUE_NOT_AVAILABLE

# TODO: Implement Tantalus test separation label update.
def update_test_separation(rocket_data: RocketData, device: DeviceType) -> str:
Expand Down
2 changes: 2 additions & 0 deletions profiles/rockets/tantalus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
update_max_altitude,
update_pressure,
update_state,
update_signal_strength
)
from ..rocket_profile import RocketProfile, FlightPoint
from connections.serial.serial_connection import SerialConnection
Expand Down Expand Up @@ -51,6 +52,7 @@ def labels(self):
Label(DeviceType.TANTALUS_STAGE_1_FLARE, "Pressure", update_pressure),
Label(DeviceType.TANTALUS_STAGE_1_FLARE, "Acceleration", update_acceleration),
Label(DeviceType.TANTALUS_STAGE_2_FLARE, "Stage2State", update_state, "Stage 2 State"),
Label(DeviceType.TANTALUS_STAGE_1_FLARE, "SignalStrength", update_signal_strength, "Signal Strength")
]

@property
Expand Down