Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.
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
4 changes: 2 additions & 2 deletions HITL-tests/comms_driver_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from communications.satellite_radio import Radio
from communications.command_handler import CommandHandler
from fsw.communications.satellite_radio import Radio
from fsw.communications.command_handler import CommandHandler
import time

# Setup
Expand Down
6 changes: 3 additions & 3 deletions HITL-tests/comms_hardware_receive.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from communications.satellite_radio import Radio
from fsw.communications.satellite_radio import Radio

#Initialize variables, nothing to modify on this end
# Initialize variables, nothing to modify on this end
transmissionCounter = 0
radio = Radio()

while True:
message = radio.receiveSignal()
if message is not None:
print(f'Transmission #{transmissionCounter} Received: {message}')
transmissionCounter += 1
transmissionCounter += 1
14 changes: 7 additions & 7 deletions HITL-tests/comms_hardware_transmit.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from communications .satellite_radio import Radio
from fsw.communications .satellite_radio import Radio
import time

#Test constants
radio = Radio() # Do not modify
signal = b'\x08\x07\x00\x00' #Pattern you want to send
interval = 3 # Number of seconds between each transmission
repetitions = 10 # Number of total times you want to transmit the pattern
# Test constants
radio = Radio() # Do not modify
signal = b'\x08\x07\x00\x00' # Pattern you want to send
interval = 3 # Number of seconds between each transmission
repetitions = 10 # Number of total times you want to transmit the pattern

for i in range(1, repetitions+1):
radio.transmit(signal)
print('Transmitted: ' + str(i))
time.sleep(interval)
time.sleep(interval)
26 changes: 13 additions & 13 deletions HITL-tests/comms_security_test.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from communications.satellite_radio import Radio
from communications.commands import CommandHandler
from communications.downlink import DownlinkHandler
from fsw.communications.satellite_radio import Radio
from fsw.communications.commands import CommandHandler
from fsw.communications.downlink import DownlinkHandler
import time

#Setup
# Setup
ch = CommandHandler()
groundstation = Radio()

#Invalid counter
#badCounterCommand = ch.pack_command(2,8,7)
#groundstation.transmit(badCounterCommand)
# Invalid counter
# badCounterCommand = ch.pack_command(2,8,7)
# groundstation.transmit(badCounterCommand)

#Invalid MAC
#invalidMAC = ch.pack_command(1,8,7)
#groundstation.transmit(invalidMAC)
# Invalid MAC
# invalidMAC = ch.pack_command(1,8,7)
# groundstation.transmit(invalidMAC)

#Shutdown via command
shutdown = ch.pack_command(1,8,11)
groundstation.transmit(shutdown)
# Shutdown via command
shutdown = ch.pack_command(1, 8, 11)
groundstation.transmit(shutdown)
40 changes: 20 additions & 20 deletions HITL-tests/file_transmitter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from utils.constants import MIN_COMMAND_SIZE, FMEnum, CommandCommandEnum, FLIGHT_SOFTWARE_PATH
from communications.satellite_radio import Radio
from communications.commands import CommandHandler
from communications.downlink import DownlinkHandler
from fsw.utils.constants import MIN_COMMAND_SIZE, FMEnum, CommandCommandEnum, FLIGHT_SOFTWARE_PATH
from fsw.communications.satellite_radio import Radio
from fsw.communications.commands import CommandHandler
from fsw.communications.downlink import DownlinkHandler
import hashlib
import time

Expand All @@ -11,17 +11,17 @@
command_counter = 1
transmission_interval = 0
satellite_file_path = 'main.py'
file_path= FLIGHT_SOFTWARE_PATH + 'FlightSoftware/' + satellite_file_path
file_path = FLIGHT_SOFTWARE_PATH + 'FlightSoftware/' + satellite_file_path

#Set file to be updated
# Set file to be updated
update_file_name = ch.pack_command(command_counter, FMEnum.Command.value,
CommandCommandEnum.SetUpdatePath.value, file_path=satellite_file_path)
CommandCommandEnum.SetUpdatePath.value, file_path=satellite_file_path)
groundstation.transmit(update_file_name)
print('File name set')
command_counter += 1

#Get file
#Max transmission size - space alotted for file name - block number -
# Get file
# Max transmission size - space alotted for file name - block number -
# min command size - 2*(2 bytes for string length)
max_string_size = 195 - MIN_COMMAND_SIZE - 4
file = open(file_path)
Expand All @@ -30,30 +30,30 @@
checksum = str(hashlib.md5(file_string.encode('utf-8')).hexdigest())
print('File Checksum: ' + checksum)

#Determine number of blocks
# Determine number of blocks
number_of_blocks = len(file_string)//max_string_size
if len(file_string) % max_string_size != 0:
number_of_blocks += 1

for i in range(number_of_blocks):
block_text = file_string[i*max_string_size:(i+1)*max_string_size]
file_blocks.append((i,block_text))
file_blocks.append((i, block_text))

i = 0
#Transmit blocks
# Transmit blocks
for block in file_blocks:
block_command = ch.pack_command(command_counter, FMEnum.Command.value,
CommandCommandEnum.AddFileBlock.value,
block_number = block[0],block_text = block[1])

block_command = ch.pack_command(command_counter, FMEnum.Command.value,
CommandCommandEnum.AddFileBlock.value,
block_number=block[0], block_text=block[1])

groundstation.transmit(block_command)
print('Transmitted Block #' + str(block[0]))
time.sleep(transmission_interval)
command_counter+= 1
command_counter += 1

file_info_request = ch.pack_command(command_counter, FMEnum.Command.value,
CommandCommandEnum.GetFileBlocksInfo.value,total_blocks=number_of_blocks)
CommandCommandEnum.GetFileBlocksInfo.value, total_blocks=number_of_blocks)
groundstation.transmit(file_info_request)
command_counter += 1
print('Receiving...')
Expand All @@ -67,8 +67,8 @@

if file_info[4]['checksum'] == checksum:
activate_file_command = ch.pack_command(command_counter, FMEnum.Command.value,
CommandCommandEnum.ActivateFile.value,total_blocks=number_of_blocks)
CommandCommandEnum.ActivateFile.value, total_blocks=number_of_blocks)
groundstation.transmit(activate_file_command)
print('File Activated')
else:
print('Missing blocks: ' + file_info[4]['missing_blocks'])
print('Missing blocks: ' + file_info[4]['missing_blocks'])
46 changes: 23 additions & 23 deletions HITL-tests/flight_unit_downlink.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
from communications.satellite_radio import Radio
from drivers.gom import Gomspace
import utils.parameters as params
from fsw.communications.satellite_radio import Radio
from fsw.drivers.gom import Gomspace
import fsw.utils.parameters as params
from time import sleep

radio = Radio()
gom = Gomspace()
electrolyzing = False

interval = 3 # Number of seconds between each transmission
repetitions = 5 # Number of total times you want to transmit the pattern
downlink = b'\x08\x07\x00\x00' #Message you want to downlink
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
interval = 3 # Number of seconds between each transmission
repetitions = 5 # Number of total times you want to transmit the pattern
downlink = b'\x08\x07\x00\x00' # Message you want to downlink
# –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# Enter Transmit Mode
#Stop electrolyzing

# Stop electrolyzing
if gom.is_electrolyzing():
electrolyzing = True
gom.set_electrolysis(False)
print('Electrolyzers turned off')

#Set RF receiving side to low
# Set RF receiving side to low
gom.rf_receiving_switch(receive=False)
print('RF Receiving set to low')

#Turn off LNA
# Turn off LNA
gom.lna(False)
print('LNA turned off')

#Set RF transmitting side to high
# Set RF transmitting side to high
gom.rf_transmitting_switch(receive=False)
print('RF transmitting set to high')

#Turn on power amplifier
# Turn on power amplifier
gom.set_pa(on=True)
print('Power amplifier turned on')
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
#Downlink
# –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# Downlink
radio.transmit(downlink)
for i in range(1, repetitions+1):
radio.transmit(downlink)
print('Transmitted: ' + str(i))
sleep(interval)
#–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
#Enter Receiving Mode
# –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
# Enter Receiving Mode

#Turn off power amplifier
# Turn off power amplifier
gom.set_pa(on=False)
print('Power amplifier turned off')

#Set RF transmitting side to low
# Set RF transmitting side to low
gom.rf_transmitting_switch(receive=True)
print('RF transmitting set to low')

#Turn on LNA
# Turn on LNA
gom.lna(True)
print('LNA turned on')

#Set RF receiving side to high
# Set RF receiving side to high
gom.rf_receiving_switch(receive=True)
print('RF receiving set to high')

#Resume electrolysis if we paused it to transmit
# Resume electrolysis if we paused it to transmit
if electrolyzing:
gom.set_electrolysis(True,delay = params.DEFAULT_ELECTROLYSIS_DELAY)
gom.set_electrolysis(True, delay=params.DEFAULT_ELECTROLYSIS_DELAY)
print('Electrolysis Resumed with Delay ' + str(params.DEFAULT_ELECTROLYSIS_DELAY))
14 changes: 7 additions & 7 deletions HITL-tests/flight_unit_receive.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from communications.satellite_radio import Radio
from drivers.gom import Gomspace
from fsw.communications.satellite_radio import Radio
from fsw.drivers.gom import Gomspace

radio = Radio()
gom = Gomspace()
transmissionCounter = 0

#Turn off power amplifier
# Turn off power amplifier
gom.set_pa(on=False)
print('Power amplifier turned off')

#Set RF transmitting side to low
# Set RF transmitting side to low
gom.rf_transmitting_switch(receive=True)
print('RF transmitting set to low')

#Turn on LNA
# Turn on LNA
gom.lna(True)
print('LNA turned on')

#Set RF receiving side to high
# Set RF receiving side to high
gom.rf_receiving_switch(receive=True)
print('RF receiving set to high')

while True:
message = radio.receiveSignal()
if message is not None:
print('Transmission #' + transmissionCounter + ' Received: ' + str(message))
transmissionCounter += 1
transmissionCounter += 1
4 changes: 2 additions & 2 deletions HITL-tests/gom_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Be careful though when hardware is connected - the ipython notebook
# does NOT have the same precautionary measures in place that are defined in this file.

from drivers.gom import Gomspace
import drivers.power.power_structs as ps
from fsw.drivers.gom import Gomspace
import fsw.drivers.power.power_structs as ps
from time import sleep
import logging

Expand Down
2 changes: 1 addition & 1 deletion HITL-tests/gyro_bias_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from drivers.imu import Gyro
from fsw.drivers.imu import Gyro
import numpy as np
import logging
from typing import List
Expand Down
4 changes: 2 additions & 2 deletions HITL-tests/hitl_groundstation_rx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from communications.satellite_radio import Radio
from communications.command_handler import CommandHandler
from fsw.communications.satellite_radio import Radio
from fsw.communications.command_handler import CommandHandler
groundstation = Radio()
dh = CommandHandler(None)

Expand Down
10 changes: 5 additions & 5 deletions HITL-tests/hitl_groundstation_tx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from communications.groundstation import Groundstation
from communications.commands import CommandHandler
from communications.downlink import DownlinkHandler
from flight_modes.flight_mode_factory import FLIGHT_MODE_DICT
from fsw.communications.groundstation import Groundstation
from fsw.communications.commands import CommandHandler
from fsw.communications.downlink import DownlinkHandler
from fsw.flight_modes.flight_mode_factory import FLIGHT_MODE_DICT
import time
import logging

Expand Down Expand Up @@ -29,7 +29,7 @@

signIndex = argsList[i].index("=")
argName = argsList[i][:signIndex]
argValue = argsList[i][signIndex + 1 :]
argValue = argsList[i][signIndex + 1:]

arg_type = FLIGHT_MODE_DICT[mode_id].command_arg_types[argName]
if arg_type == "int" or arg_type == "short":
Expand Down
8 changes: 4 additions & 4 deletions HITL-tests/signal_test_satellite.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import communications.satellite_radio as sr
from communications.serialization import DataHandler
import fsw.communications.satellite_radio as sr
from fsw.communications.serialization import DataHandler
import board
import busio
import time
from adafruit_bus_device.spi_device import SPIDevice
from communications.ax5043_manager.ax5043_driver import Ax5043
from communications.ax5043_manager.ax5043_manager import Manager
from fsw.communications.ax5043_manager.ax5043_driver import Ax5043
from fsw.communications.ax5043_manager.ax5043_manager import Manager

# Radio setup
driver = Ax5043(SPIDevice(busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)))
Expand Down
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
2 changes: 1 addition & 1 deletion communications/ax5043_manager/ax5043_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import queue
import time
from communications.ax5043_manager.ax5043_driver import (
from fsw.communications.ax5043_manager.ax5043_driver import (
Reg,
Pwrmode,
Bits,
Expand Down
7 changes: 4 additions & 3 deletions communications/ax5043_manager/main_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import board
import busio
from adafruit_bus_device.spi_device import SPIDevice
from communications.ax5043_manager.ax5043_driver import Ax5043
from communications.ax5043_manager.ax5043_manager import Manager
from fsw.communications.ax5043_manager.ax5043_driver import Ax5043
from fsw.communications.ax5043_manager.ax5043_manager import Manager

logging.basicConfig(level=logging.DEBUG)
driver = Ax5043(SPIDevice(busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)))
Expand Down Expand Up @@ -32,7 +32,8 @@
cycles += 1
# After 30s, break for clean shutdown
# (TODO: use interrupt handler to ensure clean shutdown when killed)
if cycles >= 30: break
if cycles >= 30:
break
time.sleep(1)

mgr.tx_enabled = False
Expand Down
Loading