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);
|
||||
uint8_t contestia_tick(void);
|
||||
|
||||
void contestiaize(char* string);
|
||||
|
||||
#endif /* CONTESTIA_H */
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "samd20.h"
|
||||
#include "contestia.h"
|
||||
#include "telemetry.h"
|
||||
|
@ -99,3 +101,27 @@ uint8_t contestia_tick(void) {
|
|||
|
||||
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 "timepulse.h"
|
||||
#include "telemetry.h"
|
||||
#include "contestia.h"
|
||||
#include "rsid.h"
|
||||
#include "si_trx.h"
|
||||
#include "si_trx_defs.h"
|
||||
|
@ -46,7 +47,7 @@
|
|||
#include "spi_bitbang.h"
|
||||
#include "system/interrupt.h"
|
||||
|
||||
#define CALLSIGN "UBSEDSX"
|
||||
#define CALLSIGN "UBSEDSx"
|
||||
|
||||
/* Set the modulation mode */
|
||||
//#define RTTY
|
||||
|
@ -154,10 +155,10 @@ void output_telemetry_string(enum telemetry_t type)
|
|||
double lon_fmt = 0.0;
|
||||
uint32_t altitude = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Format
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if (type == TELEMETRY_RTTY) {
|
||||
dollars = 5; // Extra dollars for RTTY
|
||||
}
|
||||
|
||||
/* sprintf - preamble */
|
||||
memset(telemetry_string, '$', dollars);
|
||||
len = dollars;
|
||||
|
@ -221,10 +233,12 @@ void output_telemetry_string(enum telemetry_t type)
|
|||
CALLSIGN, hours, minutes, seconds, lat_fmt, lon_fmt,
|
||||
altitude, satillite_count, battery, temperature);
|
||||
|
||||
if (type == TELEMETRY_CONTESTIA) { contestiaize(telemetry_string + dollars); }
|
||||
|
||||
/* sprintf - checksum. don't include dollars */
|
||||
len += sprintf(telemetry_string + len,
|
||||
"*%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 */
|
||||
telemetry_type = TELEMETRY_RSID;
|
||||
telemetry_index = 0;
|
||||
telemetry_string_length = 6;
|
||||
telemetry_string_length = 5+1+5;
|
||||
|
||||
/* Start RSID */
|
||||
rsid_start(rsid);
|
||||
|
@ -183,7 +183,9 @@ uint8_t is_telemetry_finished(void) {
|
|||
telemetry_string_length = 0;
|
||||
|
||||
/* Turn radio off */
|
||||
si_trx_off(); radio_on = 0;
|
||||
if (radio_on) {
|
||||
si_trx_off(); radio_on = 0;
|
||||
}
|
||||
|
||||
/* De-init timer */
|
||||
timer0_tick_deinit();
|
||||
|
@ -243,8 +245,9 @@ void telemetry_tick(void) {
|
|||
|
||||
case TELEMETRY_RSID: /* ---- ---- A block mode */
|
||||
|
||||
/* Wait for 5 bit times of silence */
|
||||
if (telemetry_index < 5) {
|
||||
/* Wait for 5 bit times of silence before and after */
|
||||
if (telemetry_index != 5) {
|
||||
is_telemetry_finished();
|
||||
telemetry_index++;
|
||||
return;
|
||||
}
|
||||
|
@ -261,7 +264,7 @@ void telemetry_tick(void) {
|
|||
if (!rsid_tick()) {
|
||||
/* Force transmission finished */
|
||||
telemetry_index++;
|
||||
is_telemetry_finished(); // Returns true
|
||||
si_trx_off(); radio_on = 0;
|
||||
telemetry_gpio1_pwm_deinit();
|
||||
return;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue