integrated pcu, acu and p60 dock tests
This commit is contained in:
121
gomspace/gomspace_common.py
Normal file
121
gomspace/gomspace_common.py
Normal file
@ -0,0 +1,121 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@file gomspace_common.py
|
||||
@brief PDU2 tests
|
||||
@details All functions and classes common for all gomspace devices are defined in this file.
|
||||
@author J. Meier
|
||||
@date 17.12.2020
|
||||
"""
|
||||
|
||||
|
||||
class GomspaceDeviceActions:
|
||||
PING = bytearray([0x0, 0x0, 0x0, 0x1])
|
||||
REBOOT = bytearray([0x0, 0x0, 0x0, 0x4])
|
||||
PARAM_GET = bytearray([0x0, 0x0, 0x0, 0x00])
|
||||
PARAM_SET = bytearray([0x0, 0x0, 0x0, 0xFF])
|
||||
WDT_RESET = bytearray([0x0, 0x0, 0x0, 0x9])
|
||||
|
||||
|
||||
class TableIds:
|
||||
config = 1
|
||||
hk = 4
|
||||
|
||||
|
||||
class TableEntry:
|
||||
uint8_size = 1
|
||||
uint16_size = 2
|
||||
uint32_size = 4
|
||||
|
||||
def __init__(self, parameter_address: bytearray, parameter_size):
|
||||
self.parameter_address = parameter_address
|
||||
self.parameter_size = parameter_size
|
||||
|
||||
|
||||
class Channel:
|
||||
on = 1
|
||||
off = 0
|
||||
|
||||
|
||||
def pack_get_param_command(object_id: bytearray, table_id: int, memory_address: bytearray,
|
||||
parameter_size: int) -> bytearray:
|
||||
""" Function to generate a command to retrieve parameters like the temperature from a gomspace device.
|
||||
@param object_id: The object id of the gomspace device handler.
|
||||
@param table_id: The table id of the gomspace device
|
||||
@param memory_address: Address offset within table of the value to read.
|
||||
@param parameter_size: Size of the value to read. E.g. temperature is uint16_t and thus parameter_size is 2
|
||||
@return: The command as bytearray.
|
||||
"""
|
||||
action_id = GomspaceDeviceActions.PARAM_GET
|
||||
command = bytearray()
|
||||
command = command + object_id + action_id
|
||||
command.append(table_id)
|
||||
command = command + memory_address
|
||||
command.append(parameter_size)
|
||||
return command
|
||||
|
||||
|
||||
def pack_set_param_command(object_id: bytearray, memory_address: bytearray, parameter_size: int,
|
||||
parameter: int) -> bytearray:
|
||||
""" Function to generate a command to set a parameter
|
||||
@param object_id: The object id of the gomspace device handler.
|
||||
@param memory_address: Address offset within table of the value to set.
|
||||
@param parameter: The parameter value to set.
|
||||
@param parameter_size: Size of the value to set. There are uint8_t, uint16_t and uint32_t in the device tables.
|
||||
@return: The command as bytearray.
|
||||
"""
|
||||
action_id = GomspaceDeviceActions.PARAM_SET
|
||||
command = bytearray()
|
||||
command = command + object_id + action_id
|
||||
command = command + memory_address
|
||||
command.append(parameter_size)
|
||||
if parameter_size == 1:
|
||||
command.append(parameter)
|
||||
elif parameter_size == 2:
|
||||
byte_one = 0xFF00 & parameter >> 8
|
||||
byte_two = 0xFF & parameter
|
||||
command.append(byte_one)
|
||||
command.append(byte_two)
|
||||
elif parameter_size == 4:
|
||||
byte_one = 0xFF000000 & parameter >> 24
|
||||
byte_two = 0xFF0000 & parameter >> 16
|
||||
byte_three = 0xFF00 & parameter >> 8
|
||||
byte_four = 0xFF & parameter
|
||||
command.append(byte_one)
|
||||
command.append(byte_two)
|
||||
command.append(byte_three)
|
||||
command.append(byte_four)
|
||||
return command
|
||||
|
||||
|
||||
def pack_ping_command(object_id: bytearray, data: bytearray) -> bytearray:
|
||||
"""" Function to generate the command to ping a gomspace device
|
||||
@param object_id Object Id of the gomspace device handler.
|
||||
@param data Bytearray containing the bytes to send to the gomspace device. For now the on board software
|
||||
supports only the handling of up to 33 bytes.
|
||||
@note The ping request sends the specified data to a gompsace device. These
|
||||
data are simply copied by the device and then sent back.
|
||||
"""
|
||||
action_id = GomspaceDeviceActions.PING
|
||||
command = bytearray()
|
||||
command = object_id + action_id + data
|
||||
return command
|
||||
|
||||
|
||||
def pack_gnd_wdt_reset_command(object_id: bytearray) -> bytearray:
|
||||
"""" Function to generate the command to reset the watchdog of a gomspace device.
|
||||
@param object_id Object Id of the gomspace device handler.
|
||||
"""
|
||||
action_id = GomspaceDeviceActions.WDT_RESET
|
||||
command = bytearray()
|
||||
command = object_id + action_id
|
||||
return command
|
||||
|
||||
|
||||
def pack_reboot_command(object_id: bytearray) -> bytearray:
|
||||
""" Function to generate the command which triggers a reboot of a gomspace device
|
||||
@param object_id The object id of the gomspace device handler.
|
||||
"""
|
||||
action_id = GomspaceDeviceActions.REBOOT
|
||||
command = bytearray()
|
||||
command = object_id + action_id
|
||||
return command
|
16
gomspace/gomspace_pdu_definitions.py
Normal file
16
gomspace/gomspace_pdu_definitions.py
Normal file
@ -0,0 +1,16 @@
|
||||
from gomspace.gomspace_common import TableEntry
|
||||
|
||||
|
||||
class PDUConfigTable:
|
||||
out_en_0 = TableEntry(bytearray([0x00, 0x48]), TableEntry.uint8_size)
|
||||
out_en_1 = TableEntry(bytearray([0x00, 0x49]), TableEntry.uint8_size)
|
||||
out_en_2 = TableEntry(bytearray([0x00, 0x4A]), TableEntry.uint8_size)
|
||||
out_en_3 = TableEntry(bytearray([0x00, 0x4B]), TableEntry.uint8_size)
|
||||
# When channel consumes more than cur_lu_lim, channel is turned of immediately
|
||||
cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xB8]), TableEntry.uint16_size)
|
||||
|
||||
|
||||
class PDUHkTable:
|
||||
temperature = TableEntry(bytearray([0x00, 0x28]), TableEntry.uint16_size)
|
||||
# Ground WDT value (remaining seconds until reboot)
|
||||
wdt_gnd_left = TableEntry(bytearray([0x00, 0x80]), TableEntry.uint32_size)
|
Reference in New Issue
Block a user