1 #include "../../firmware.h"
2 #include "../../test.h"
4 bool test_packet_transmission_telecommand(
void)
7 uint16_t spacecraft_id = 0x4242;
8 uint8_t tc_sign_key[16] = { 0x45, 0xDA, 0x45, 0x92, 0xF7, 0x44, 0xD4, 0xEB,
9 0x6C, 0x81, 0x34, 0x3F, 0x9C, 0xB6, 0xE0, 0xCE };
15 uint8_t transmission_buffer[128];
18 reference_packet.spacecraft = spacecraft_id;
19 for(i=0; i<
sizeof(reference_packet.data); i++)
21 reference_packet.data[i] = (uint8_t)(
Random(255));
30 memcpy(&test_tx_packet, &reference_packet,
sizeof(test_tx_packet));
32 Packet_telecommand_512_encode(&test_tx_packet, transmission_buffer, spacecraft_id, tc_sign_key,
sizeof(tc_sign_key));
43 for(i=0; i<BIT_FLIPS; i++)
45 bit_index = (uint8_t)(
Random(
sizeof(transmission_buffer)));
46 transmission_buffer[bit_index >> 3] = (uint8_t)(transmission_buffer[bit_index >> 3] ^ (0x80 >> (bit_index & 0x07)));
50 if(!Packet_telecommand_512_decode(transmission_buffer, &test_rx_packet, spacecraft_id, tc_sign_key,
sizeof(tc_sign_key)))
64 if(memcmp(test_rx_packet.data, reference_packet.data,
sizeof(reference_packet.data)) == 0)
74 bool test_packet_transmission_telemetry(
void)
78 uint16_t spacecraft_id = 0x4242;
79 uint8_t tm_sign_key[16] = { 0x45, 0xDA, 0x82, 0xBB, 0xF7, 0x44, 0xD4, 0x98,
80 0x6C, 0xA3, 0x33, 0x3E, 0x9B, 0xB6, 0xEB, 0xCE };
86 uint8_t transmission_buffer[384];
89 reference_packet.spacecraft = spacecraft_id;
90 for(i=0; i<
sizeof(reference_packet.data); i++)
92 reference_packet.data[i] = (uint8_t)(
Random(255));
101 memcpy(&test_tx_packet, &reference_packet,
sizeof(test_tx_packet));
123 if(!Packet_telemetry_1024_decode(transmission_buffer, &test_rx_packet, spacecraft_id, tm_sign_key,
sizeof(tm_sign_key)))
137 if(memcmp(test_rx_packet.data, reference_packet.data,
sizeof(reference_packet.data)) == 0)
uint32_t Random(uint32_t max)
void Packet_telemetry_1024_encode(packet_telemetry_1024 *input_packet, uint8_t *output_buffer, const uint16_t origin, const uint8_t *key, uint32_t key_length)
void Debug_print(char *fmt,...)
void buffer_print_hex(uint8_t *buffer, uint32_t length)