kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added contestia checking function to beat checksum bug, added spacing after rsid
rodzic
b7a0d03a51
commit
7cf609819e
|
@ -38,4 +38,6 @@ void contestia_start(char* data);
|
||||||
void contestia_preamble(void);
|
void contestia_preamble(void);
|
||||||
uint8_t contestia_tick(void);
|
uint8_t contestia_tick(void);
|
||||||
|
|
||||||
|
void contestiaize(char* string);
|
||||||
|
|
||||||
#endif /* CONTESTIA_H */
|
#endif /* CONTESTIA_H */
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "samd20.h"
|
#include "samd20.h"
|
||||||
#include "contestia.h"
|
#include "contestia.h"
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
|
@ -99,3 +101,27 @@ uint8_t contestia_tick(void) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only certain strings are possible in contestia (no lowercase
|
||||||
|
* etc.). This function prases a string and fixed anything that would
|
||||||
|
* be converted by contestia transmission.
|
||||||
|
*/
|
||||||
|
void contestiaize(char* string) {
|
||||||
|
for (size_t i = 0; i < strlen(string); i++) {
|
||||||
|
|
||||||
|
/* lowercase => UPPERCASE */
|
||||||
|
if (string[i] >= 'a' && string[i] <= 'z') {
|
||||||
|
string[i] += 'A' - 'a';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((string[i] < '!' || string[i] > 'Z') && /* Not Printable */
|
||||||
|
(string[i] != ' ') && (string[i] != '\r') &&
|
||||||
|
(string[i] != '\n') && (string[i] != 8) &&
|
||||||
|
(string[i] != 0)) {
|
||||||
|
string[i] = '?'; /* Comes out as question mark */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "system/wdt.h"
|
#include "system/wdt.h"
|
||||||
#include "timepulse.h"
|
#include "timepulse.h"
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
|
#include "contestia.h"
|
||||||
#include "rsid.h"
|
#include "rsid.h"
|
||||||
#include "si_trx.h"
|
#include "si_trx.h"
|
||||||
#include "si_trx_defs.h"
|
#include "si_trx_defs.h"
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
#include "spi_bitbang.h"
|
#include "spi_bitbang.h"
|
||||||
#include "system/interrupt.h"
|
#include "system/interrupt.h"
|
||||||
|
|
||||||
#define CALLSIGN "UBSEDSX"
|
#define CALLSIGN "UBSEDSx"
|
||||||
|
|
||||||
/* Set the modulation mode */
|
/* Set the modulation mode */
|
||||||
//#define RTTY
|
//#define RTTY
|
||||||
|
@ -154,10 +155,10 @@ void output_telemetry_string(enum telemetry_t type)
|
||||||
double lon_fmt = 0.0;
|
double lon_fmt = 0.0;
|
||||||
uint32_t altitude = 0;
|
uint32_t altitude = 0;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint8_t dollars = 5;
|
uint8_t dollars = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analogue, Callsign, Time
|
* Collect Data
|
||||||
* ---------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -211,6 +212,17 @@ void output_telemetry_string(enum telemetry_t type)
|
||||||
altitude = pos.payload.height / 1000;
|
altitude = pos.payload.height / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format
|
||||||
|
* ---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (type == TELEMETRY_RTTY) {
|
||||||
|
dollars = 5; // Extra dollars for RTTY
|
||||||
|
}
|
||||||
|
|
||||||
/* sprintf - preamble */
|
/* sprintf - preamble */
|
||||||
memset(telemetry_string, '$', dollars);
|
memset(telemetry_string, '$', dollars);
|
||||||
len = dollars;
|
len = dollars;
|
||||||
|
@ -221,10 +233,12 @@ void output_telemetry_string(enum telemetry_t type)
|
||||||
CALLSIGN, hours, minutes, seconds, lat_fmt, lon_fmt,
|
CALLSIGN, hours, minutes, seconds, lat_fmt, lon_fmt,
|
||||||
altitude, satillite_count, battery, temperature);
|
altitude, satillite_count, battery, temperature);
|
||||||
|
|
||||||
|
if (type == TELEMETRY_CONTESTIA) { contestiaize(telemetry_string + dollars); }
|
||||||
|
|
||||||
/* sprintf - checksum. don't include dollars */
|
/* sprintf - checksum. don't include dollars */
|
||||||
len += sprintf(telemetry_string + len,
|
len += sprintf(telemetry_string + len,
|
||||||
"*%04X\r",
|
"*%04X\r",
|
||||||
crc_checksum(telemetry_string + 5));
|
crc_checksum(telemetry_string + dollars));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ int telemetry_start_rsid(rsid_code_t rsid) {
|
||||||
/* Initialise */
|
/* Initialise */
|
||||||
telemetry_type = TELEMETRY_RSID;
|
telemetry_type = TELEMETRY_RSID;
|
||||||
telemetry_index = 0;
|
telemetry_index = 0;
|
||||||
telemetry_string_length = 6;
|
telemetry_string_length = 5+1+5;
|
||||||
|
|
||||||
/* Start RSID */
|
/* Start RSID */
|
||||||
rsid_start(rsid);
|
rsid_start(rsid);
|
||||||
|
@ -183,7 +183,9 @@ uint8_t is_telemetry_finished(void) {
|
||||||
telemetry_string_length = 0;
|
telemetry_string_length = 0;
|
||||||
|
|
||||||
/* Turn radio off */
|
/* Turn radio off */
|
||||||
si_trx_off(); radio_on = 0;
|
if (radio_on) {
|
||||||
|
si_trx_off(); radio_on = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* De-init timer */
|
/* De-init timer */
|
||||||
timer0_tick_deinit();
|
timer0_tick_deinit();
|
||||||
|
@ -243,8 +245,9 @@ void telemetry_tick(void) {
|
||||||
|
|
||||||
case TELEMETRY_RSID: /* ---- ---- A block mode */
|
case TELEMETRY_RSID: /* ---- ---- A block mode */
|
||||||
|
|
||||||
/* Wait for 5 bit times of silence */
|
/* Wait for 5 bit times of silence before and after */
|
||||||
if (telemetry_index < 5) {
|
if (telemetry_index != 5) {
|
||||||
|
is_telemetry_finished();
|
||||||
telemetry_index++;
|
telemetry_index++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +264,7 @@ void telemetry_tick(void) {
|
||||||
if (!rsid_tick()) {
|
if (!rsid_tick()) {
|
||||||
/* Force transmission finished */
|
/* Force transmission finished */
|
||||||
telemetry_index++;
|
telemetry_index++;
|
||||||
is_telemetry_finished(); // Returns true
|
si_trx_off(); radio_on = 0;
|
||||||
telemetry_gpio1_pwm_deinit();
|
telemetry_gpio1_pwm_deinit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue