Skip to content

Commit 859a35c

Browse files
committed
src: beacon: Adding debug messages
1 parent ac43275 commit 859a35c

File tree

5 files changed

+106
-27
lines changed

5 files changed

+106
-27
lines changed

firmware/fsat_beacon_msp430/src/beacon.c

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
2727
*
28-
* \version 0.1.7
28+
* \version 0.1.11
2929
*
3030
* \date 08/06/2017
3131
*
@@ -112,7 +112,7 @@ void beacon_deinit()
112112

113113
void beacon_run()
114114
{
115-
debug_print_event(DEBUG_INFO, "Running...\n\r");
115+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Running main loop...\n\r");
116116

117117
// if (!antenna_is_released())
118118
// {
@@ -161,7 +161,7 @@ void beacon_enter_hibernation()
161161
{
162162
if (!beacon.hibernation)
163163
{
164-
debug_print_event(DEBUG_INFO, "Entering in hibernation mode...\n\r");
164+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Entering in hibernation mode...\n\r");
165165

166166
radio_sleep();
167167

@@ -173,7 +173,7 @@ void beacon_enter_hibernation()
173173

174174
void beacon_leave_hibernation()
175175
{
176-
debug_print_event(DEBUG_INFO, "Leaving hibernation mode...\n\r");
176+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Leaving hibernation mode...\n\r");
177177

178178
radio_wake_up();
179179

@@ -201,6 +201,8 @@ uint8_t beacon_get_tx_period()
201201

202202
void beacon_set_energy_level()
203203
{
204+
uint8_t last_energy_level = beacon.energy_level;
205+
204206
if ((beacon.obdh.errors == 0) && (!beacon.obdh.is_dead))
205207
{
206208
beacon.energy_level = beacon.obdh.buffer.data[OBDH_PKT_ENERGY_LEVEL_POS];
@@ -213,10 +215,22 @@ void beacon_set_energy_level()
213215
{
214216
beacon.energy_level = SATELLITE_ENERGY_LEVEL_5;
215217
}
218+
219+
if (last_energy_level != beacon.energy_level)
220+
{
221+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Changing energy level from ");
222+
debug_print_dec(last_energy_level);
223+
debug_print_msg(" to ");
224+
debug_print_dec(beacon.energy_level);
225+
debug_print_msg("!\n\r");
226+
}
216227
}
217228

218229
void beacon_check_devices_status()
219230
{
231+
bool last_obdh_status = beacon.obdh.is_dead;
232+
bool last_eps_status = beacon.eps.is_dead;
233+
220234
if ((time_get_seconds() - beacon.obdh.time_last_valid_pkt) <= OBDH_TIMEOUT_SEC)
221235
{
222236
beacon.obdh.is_dead = false;
@@ -245,11 +259,21 @@ void beacon_check_devices_status()
245259

246260
// Antenna connection status
247261
// Radio status
262+
263+
if (last_obdh_status != beacon.obdh.is_dead)
264+
{
265+
debug_print_event_from_module(DEBUG_ERROR, BEACON_MODULE_NAME, "The OBDH module is not responding!\n\r");
266+
}
267+
268+
if (last_eps_status != beacon.eps.is_dead)
269+
{
270+
debug_print_event_from_module(DEBUG_ERROR, BEACON_MODULE_NAME, "The EPS module is not responding!\n\r");
271+
}
248272
}
249273

250274
void beacon_gen_pkt_payload()
251275
{
252-
debug_print_event(DEBUG_INFO, "Generating packet payload from ");
276+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Generating packet payload from ");
253277

254278
if (!buffer_empty(&beacon.pkt_payload))
255279
{
@@ -286,20 +310,24 @@ void beacon_gen_pkt_payload()
286310

287311
void beacon_gen_ngham_pkt(uint8_t *ngham_pkt_str, uint16_t *ngham_pkt_str_len)
288312
{
313+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Generating a NGHam packet...\n\r");
314+
289315
beacon_gen_pkt_payload();
290-
316+
291317
NGHam_TX_Packet ngham_packet;
292-
318+
293319
ngham_tx_pkt_gen(&ngham_packet, beacon.pkt_payload.data, beacon.pkt_payload.size);
294320
ngham_encode(&ngham_packet, ngham_pkt_str, ngham_pkt_str_len);
295321
}
296322

297323
void beacon_gen_ax25_pkt(uint8_t *ax25_pkt_str, uint16_t *ax25_pkt_str_len)
298324
{
325+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Generating a AX.25 packet...\n\r");
326+
299327
beacon_gen_pkt_payload();
300-
328+
301329
AX25_Packet ax25_packet;
302-
330+
303331
ax25_beacon_pkt_gen(&ax25_packet, beacon.pkt_payload.data, beacon.pkt_payload.size);
304332
ax25_encode(&ax25_packet, ax25_pkt_str, ax25_pkt_str_len);
305333
}
@@ -310,15 +338,17 @@ void beacon_send_ngham_pkt()
310338
{
311339
if (beacon.can_transmit)
312340
{
341+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Transmitting a NGHam packet...\n\r");
342+
313343
uint8_t ngham_pkt_str[256];
314344
uint16_t ngham_pkt_str_len;
315-
345+
316346
beacon_gen_ngham_pkt(ngham_pkt_str, &ngham_pkt_str_len);
317-
347+
318348
beacon.transmitting = true;
319-
349+
320350
radio_write(ngham_pkt_str+8, ngham_pkt_str_len-8); // 8: Removing preamble and sync word from the NGHam packet
321-
351+
322352
beacon.transmitting = false;
323353
}
324354
}
@@ -330,15 +360,17 @@ void beacon_send_ax25_pkt()
330360
{
331361
if (beacon.can_transmit)
332362
{
333-
beacon.transmitting = true;
334-
363+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Transmitting a AX.25 packet...\n\r");
364+
335365
uint8_t ax25_pkt_str[256];
336366
uint16_t ax25_pkt_str_len;
337-
367+
338368
beacon_gen_ax25_pkt(ax25_pkt_str, &ax25_pkt_str_len);
339-
369+
370+
beacon.transmitting = true;
371+
340372
radio_write(ax25_pkt_str, ax25_pkt_str_len);
341-
373+
342374
beacon.transmitting = false;
343375
}
344376
}
@@ -556,7 +588,7 @@ void beacon_process_radio_pkt()
556588
{
557589
uint8_t i = 0;
558590

559-
debug_print_event(DEBUG_INFO, "Shutdown command received from ");
591+
debug_print_event_from_module(DEBUG_INFO, BEACON_MODULE_NAME, "Shutdown command received from ");
560592
for(i=0; i<6; i++)
561593
{
562594
debug_print_byte(data[i]);

firmware/fsat_beacon_msp430/src/beacon.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*
22
* beacon.h
33
*
4-
* Copyright (C) 2017, Federal University of Santa Catarina.
4+
* Copyright (C) 2017-2019, Universidade Federal de Santa Catarina.
55
*
6-
* This file is part of FloripaSat-Beacon.
6+
* This file is part of FloripaSat-TTC.
77
*
8-
* FloripaSat-Beacon is free software: you can redistribute it and/or modify
8+
* FloripaSat-TTC is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
1212
*
13-
* FloripaSat-Beacon is distributed in the hope that it will be useful,
13+
* FloripaSat-TTC is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU General Public License for more details.
1717
*
1818
* You should have received a copy of the GNU General Public License
19-
* along with FloripaSat-Beacon. If not, see <http://www.gnu.org/licenses/>.
19+
* along with FloripaSat-TTC. If not, see <http://www.gnu.org/licenses/>.
2020
*
2121
*/
2222

@@ -25,7 +25,7 @@
2525
*
2626
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
2727
*
28-
* \version 1.0-dev
28+
* \version 0.1.11
2929
*
3030
* \date 08/06/2017
3131
*
@@ -44,6 +44,8 @@
4444

4545
#include "fsat_module.h"
4646

47+
#define BEACON_MODULE_NAME "Beacon"
48+
4749
/**
4850
* \brief Beacon variables struct.
4951
*/

firmware/fsat_beacon_msp430/src/ngham/ngham.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* \author Jon Petter Skagmo <web@skagmo.com>
2828
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
2929
*
30+
* \version 0.1.11
31+
*
3032
* \date 10/02/2017
3133
*
3234
* \addtogroup ngham
@@ -43,6 +45,8 @@
4345

4446
#include <stdio.h>
4547

48+
#include <system/system.h>
49+
4650
// There are seven different sizes.
4751
// Each size has a correlation tag for size, a total size, a maximum payload size and a parity data size.
4852
const uint8_t NGH_PL_SIZE[] = {28, 60, 92, 124, 156, 188, 220}; // Actual payload
@@ -72,13 +76,17 @@ RS rs_cb[NGH_SIZES];
7276

7377
void ngham_init()
7478
{
79+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Initializing...\n\r");
80+
7581
decoder_state = NGH_STATE_SIZE_TAG;
7682

7783
ngham_init_arrays();
7884
}
7985

8086
void ngham_init_arrays()
8187
{
88+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Initializing arrays...\n\r");
89+
8290
uint8_t i;
8391
for(i=0;i<NGH_SIZES;i++)
8492
{
@@ -97,6 +105,8 @@ void ngham_init_arrays()
97105

98106
void ngham_deinit_arrays()
99107
{
108+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Deinitializing arrays...\n\r");
109+
100110
free_rs_char(&rs_cb[0]); // Free memory for nroots = 16
101111
free_rs_char(&rs_cb[3]); // Free memory for nroots = 32
102112
}
@@ -146,6 +156,19 @@ static uint8_t ngham_tag_check(uint32_t x, uint32_t y)
146156
void ngham_encode(NGHam_TX_Packet *p, uint8_t *pkt, uint16_t *pkt_len)
147157
{
148158
uint16_t j;
159+
160+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Encoding a new packet: ");
161+
for(j=0; j<p->pl_len; j++)
162+
{
163+
debug_print_hex(p->pl[j]);
164+
165+
if (j < p->pl_len-1)
166+
{
167+
debug_print_msg(", ");
168+
}
169+
}
170+
debug_print_msg("\n\r");
171+
149172
uint16_t crc;
150173
uint8_t size_nr = 0;
151174
uint8_t d[NGH_MAX_TOT_SIZE];
@@ -222,6 +245,8 @@ void ngham_encode(NGHam_TX_Packet *p, uint8_t *pkt, uint16_t *pkt_len)
222245

223246
uint8_t ngham_decode(uint8_t d, uint8_t *msg, uint8_t *msg_len)
224247
{
248+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Decoding an incoming packet...\n\r");
249+
225250
static uint8_t size_nr;
226251
static uint32_t size_tag;
227252
static uint16_t length;
@@ -299,11 +324,27 @@ uint8_t ngham_decode(uint8_t d, uint8_t *msg, uint8_t *msg_len)
299324
rx_pkt.noise = ngham_action_get_noise_floor();
300325
rx_pkt.rssi = ngham_action_get_rssi();
301326
ngham_action_handle_packet(PKT_CONDITION_OK, &rx_pkt, msg, msg_len);
327+
328+
debug_print_event_from_module(DEBUG_INFO, NGHAM_MODULE_NAME, "Decoded packat: ");
329+
uint16_t i;
330+
for(i; i<*msg_len; i++)
331+
{
332+
debug_print_hex(msg[i]);
333+
334+
if (i < *msg_len-1)
335+
{
336+
debug_print_msg(", ");
337+
}
338+
}
339+
debug_print_msg("\n\r");
340+
302341
return PKT_CONDITION_OK;
303342
}
304343
// If packet decoding not was successful, count this as an error
305344
else
306345
{
346+
debug_print_event_from_module(DEBUG_ERROR, NGHAM_MODULE_NAME, "Error during packet decoding! Maybe the packet is corrupted!\n\r");
347+
307348
ngham_action_handle_packet(PKT_CONDITION_FAIL, NULL, NULL, NULL);
308349
return PKT_CONDITION_FAIL;
309350
}

firmware/fsat_beacon_msp430/src/ngham/ngham.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* \author Jon Petter Skagmo <web@skagmo.com>
2828
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
2929
*
30+
* \version 0.1.11
31+
*
3032
* \date 10/02/2017
3133
*
3234
* \defgroup ngham NGHam
@@ -82,6 +84,8 @@
8284
#define NGH_HAMMING_DISTANCE_GREATER 0x00
8385
#define NGH_HAMMING_DISTANCE_SMALLER 0x01
8486

87+
#define NGHAM_MODULE_NAME "NGHam"
88+
8589
extern const uint8_t NGH_PL_SIZE[]; /**< Actual payload. */
8690
extern const uint8_t NGH_PL_SIZE_FULL[]; /**< Size with LEN, payload and CRC. */
8791
extern const uint8_t NGH_PL_PAR_SIZE[]; /**< Size with RS parity added. */

firmware/fsat_beacon_msp430/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
2727
*
28-
* \version 0.1.10
28+
* \version 0.1.11
2929
*
3030
* \date 08/02/2019
3131
*
@@ -36,7 +36,7 @@
3636
#ifndef VERSION_H_
3737
#define VERSION_H_
3838

39-
#define FIRMWARE_VERSION "0.1.10"
39+
#define FIRMWARE_VERSION "0.1.11"
4040

4141
#define FIRMWARE_STATUS "Development"
4242

0 commit comments

Comments
 (0)