Implemented camera buffer overflow protection

Moved definitions around
Changed Isol (PAC1720) measurement implementation
Reimplemented logging and log transmission
Changed Sleep implementation
Develop
Sven Steudte 2017-06-30 23:23:51 +02:00
rodzic 92011ea8e3
commit 7b9e236076
12 zmienionych plików z 206 dodań i 395 usunięć

Wyświetl plik

@ -3,8 +3,8 @@
#include "debug.h"
module_conf_t config[9];
uint8_t ssdv_buffer[1024*50];
uint8_t ssdv_buffer2[1024*100];
uint8_t ssdv_buffer[65535];
uint8_t ssdv_buffer2[65535];
/*
* Position module configuration description
@ -178,21 +178,43 @@ void start_user_modules(void)
config[0].frequency.hz = 144800000; // Default frequency 144.800 MHz
config[0].init_delay = 0; // Module startup delay in msec
config[0].trigger.type = TRIG_NEW_POINT; // Trigger when new track point released
chsnprintf(config[0].aprs_conf.callsign, 6, "DL7AD"); // APRS Callsign
config[0].aprs_conf.ssid = 12; // APRS SSID
chsnprintf(config[0].aprs_conf.callsign, 6, "DK0TU"); // APRS Callsign
config[0].aprs_conf.ssid = 11; // APRS SSID
config[0].aprs_conf.symbol = SYM_BALLOON; // APRS Symbol
chsnprintf(config[0].aprs_conf.path, 16, "WIDE1-1"); // APRS Path
config[0].aprs_conf.preamble = 300; // APRS Preamble
config[0].aprs_conf.tel[0] = TEL_VBAT; // APRS Telemetry parameter 1
config[0].aprs_conf.tel[1] = TEL_VSOL; // APRS Telemetry parameter 2
config[0].aprs_conf.tel[2] = TEL_TEMP; // APRS Telemetry parameter 3
config[0].aprs_conf.tel[3] = TEL_PBAT; // APRS Telemetry parameter 4
config[0].aprs_conf.tel[4] = TEL_ISOL; // APRS Telemetry parameter 5
config[0].aprs_conf.tel[1] = TEL_TEMP; // APRS Telemetry parameter 2
config[0].aprs_conf.tel[2] = TEL_PRESS; // APRS Telemetry parameter 3
config[0].aprs_conf.tel[3] = TEL_HUM; // APRS Telemetry parameter 4
config[0].aprs_conf.tel[4] = TEL_SATS; // APRS Telemetry parameter 5
config[0].aprs_conf.tel_enc = TRUE; // Transmit Telemetry encoding information activated
config[0].aprs_conf.tel_enc_cycle = 3600; // Transmit Telemetry encoding information every 3600sec
chsnprintf(config[0].aprs_conf.tel_comment, 18, "http://tkrahn.org");// Telemetry comment
chsnprintf(config[0].aprs_conf.tel_comment, 30, "http://ssdv.habhub.org/DL4MDW");// Telemetry comment
start_position_thread(&config[0]);
// Module POSITION, APRS 2m AFSK
/*config[0].power = 127; // Power 20 dBm
config[0].protocol = PROT_APRS_AFSK; // Protocol APRS, modulation AFSK
config[0].frequency.type = FREQ_APRS_REGION; // Dynamic frequency allocation
config[0].frequency.hz = 144800000; // Default frequency 144.800 MHz
config[0].init_delay = 30000; // Module startup delay in msec
config[0].trigger.type = TRIG_NEW_POINT; // Trigger when new track point released
chsnprintf(config[0].aprs_conf.callsign, 7, "DL4MDW"); // APRS Callsign
config[0].aprs_conf.ssid = 14; // APRS SSID
config[0].aprs_conf.symbol = SYM_BALLOON; // APRS Symbol
chsnprintf(config[0].aprs_conf.path, 16, "WIDE1-1"); // APRS Path
config[0].aprs_conf.preamble = 300; // APRS Preamble
config[0].aprs_conf.tel[0] = TEL_SATS; // APRS Telemetry parameter 1
config[0].aprs_conf.tel[1] = TEL_TTFF; // APRS Telemetry parameter 2
config[0].aprs_conf.tel[2] = TEL_PRESS; // APRS Telemetry parameter 3
config[0].aprs_conf.tel[3] = TEL_TEMP; // APRS Telemetry parameter 4
config[0].aprs_conf.tel[4] = TEL_HUM; // APRS Telemetry parameter 5
config[0].aprs_conf.tel_enc = TRUE; // Transmit Telemetry encoding information activated
config[0].aprs_conf.tel_enc_cycle = 3600; // Transmit Telemetry encoding information every 3600sec
chsnprintf(config[0].aprs_conf.tel_comment, 30, "http://ssdv.habhub.org/DL4MDW");// Telemetry comment
start_position_thread(&config[0]);*/
// Module POSITION, APRS 2m 2GFSK
/*config[1].power = 127; // Power 10 dBm
config[1].protocol = PROT_APRS_2GFSK; // Protocol APRS, modulation 2GFSK
@ -233,23 +255,25 @@ void start_user_modules(void)
start_position_thread(&config[2]);*/
// Module IMAGE, APRS 2m AFSK low-duty cycle
config[3].power = 127; // Power 20 dBm
/*config[3].power = 127; // Power 20 dBm
config[3].protocol = PROT_APRS_AFSK; // Protocol APRS SSDV, modulation AFSK
config[3].frequency.type = FREQ_APRS_REGION; // Dynamic frequency allocation
config[3].frequency.hz = 144800000; // Transmission frequency 144.800 MHz
config[3].init_delay = 2000; // Module startup delay in msec
config[3].init_delay = 10000; // Module startup delay in msec
config[3].packet_spacing = 20000; // Packet spacing in ms
config[3].sleep_conf.type = SLEEP_WHEN_ISOL_BELOW_THRES;
config[3].sleep_conf.isol_thres = 3;
config[3].trigger.type = TRIG_TIMEOUT; // Trigger transmission on timeout (Periodic cycling)
config[3].trigger.timeout = 10; // Timeout 10 sec
chsnprintf(config[3].aprs_conf.callsign, 6, "DL7AD"); // APRS Callsign
chsnprintf(config[3].aprs_conf.callsign, 7, "DL4MDW"); // APRS Callsign
config[3].aprs_conf.ssid = 12; // APRS SSID
config[3].aprs_conf.preamble = 300; // APRS Preamble
chsnprintf(config[3].ssdv_conf.callsign, 6, "DL7AD"); // SSDV Callsign
chsnprintf(config[3].ssdv_conf.callsign, 7, "DL4MDW"); // SSDV Callsign
config[3].ssdv_conf.ram_buffer = ssdv_buffer; // Camera buffer
config[3].ssdv_conf.ram_size = sizeof(ssdv_buffer); // Buffer size
config[3].ssdv_conf.res = RES_QVGA; // Resolution VGA
config[3].ssdv_conf.redundantTx = true; // Transmit packets twice
start_image_thread(&config[3]);
start_image_thread(&config[3]);*/
// Module POSITION, Morse 2m OOK
/*config[4].power = 127; // Power 10 dBm
@ -265,22 +289,23 @@ void start_user_modules(void)
start_position_thread(&config[4]);*/
// Module IMAGE, APRS 2m 2GFSK
/*config[5].power = 127; // Power 20 dBm
config[5].power = 127; // Power 20 dBm
config[5].protocol = PROT_APRS_2GFSK; // Protocol APRS SSDV, modulation 2GFSK
config[5].gfsk_conf.speed = 9600; // 2GFSK Speed
config[5].frequency.type = FREQ_STATIC; // Static frequency allocation
config[5].frequency.hz = 144860000; // Transmission frequency 144.860 MHz
config[5].init_delay = 4000; // Module startup delay in msec
config[5].init_delay = 120000; // Module startup delay in msec
config[5].trigger.type = TRIG_TIMEOUT; // Trigger transmission on timeout (Periodic cycling)
config[5].trigger.timeout = 2; // Timeout 10 sec
chsnprintf(config[5].aprs_conf.callsign, 6, "DL7AD"); // APRS Callsign
config[5].aprs_conf.ssid = 12; // APRS SSID
chsnprintf(config[5].aprs_conf.callsign, 6, "DK0TU"); // APRS Callsign
config[5].aprs_conf.ssid = 11; // APRS SSID
config[5].aprs_conf.preamble = 50; // APRS Preamble
chsnprintf(config[5].ssdv_conf.callsign, 6, "DL7AD"); // SSDV Callsign
chsnprintf(config[5].ssdv_conf.callsign, 6, "DK0TU"); // SSDV Callsign
config[5].ssdv_conf.ram_buffer = ssdv_buffer2; // Camera buffer
config[5].ssdv_conf.ram_size = sizeof(ssdv_buffer2); // Buffer size
config[5].ssdv_conf.res = RES_QVGA; // Resolution XGA
start_image_thread(&config[5]);*/
config[5].ssdv_conf.redundantTx = true; // Transmit packets twice
start_image_thread(&config[5]);
// Module IMAGE, SSDV 2m 2FSK
/*config[6].power = 127; // Power 20 dBm
@ -303,17 +328,17 @@ void start_user_modules(void)
start_image_thread(&config[6]);*/
// Module LOG, APRS 2m AFSK
/*config[8].power = 127; // Power 20 dBm
/*config[8].power = 127; // Power 20 dBm
config[8].protocol = PROT_APRS_AFSK; // Protocol APRS, modulation AFSK
config[8].frequency.type = FREQ_APRS_REGION; // Dynamic frequency allocation
config[8].frequency.hz = 144800000; // Default frequency 144.800 MHz
config[8].init_delay = 10000; // Module startup delay in msec
config[8].trigger.type = TRIG_TIMEOUT; // Trigger transmission on timeout (Periodic cycling)
config[8].trigger.timeout = 600; // Timeout 600 sec
chsnprintf(config[8].aprs_conf.callsign, 6, "DL7AD"); // APRS Callsign
config[8].trigger.timeout = 180; // Timeout 600 sec
chsnprintf(config[8].aprs_conf.callsign, 7, "DL4MDW"); // APRS Callsign
config[8].aprs_conf.ssid = 12; // APRS SSID
chsnprintf(config[8].aprs_conf.path, 16, "WIDE1-1"); // APRS Path
config[8].aprs_conf.preamble = 500; // APRS Preamble
config[8].aprs_conf.preamble = 300; // APRS Preamble
start_logging_thread(&config[8]);*/
}

Wyświetl plik

@ -8,14 +8,16 @@
#include "radio.h"
#include "sleep.h"
//extern module_conf_t config[9];
#define TRACK_CYCLE_TIME 180 /* Tracking cycle (all peripheral data [airpressure, GPS, temperature, ...] is collected each x seconds */
#define TRACK_CYCLE_TIME 30 /* Tracking cycle (all peripheral data [airpressure, GPS, temperature, ...] is collected each x seconds */
#define LOG_CYCLE_TIME 1800 /* Log cycle time in seconds */
#define LOG_CYCLE_TIME 30 /* Log cycle time in seconds */
#define LOG_FLASH_ADDR1 0x080C0000 /* Log flash memory address 1 */
#define LOG_FLASH_ADDR2 0x080E0000 /* Log flash memory address 2 */
#define LOG_SECTOR_SIZE 0x20000 /* Log flash memory size */
#define GPS_ON_VBAT 2500 /* Battery voltage threshold at which GPS is switched on */
#define GPS_OFF_VBAT 3000 /* Battery voltage threshold at which GPS is switched off */
#define GPS_ON_VBAT 1000 /* Battery voltage threshold at which GPS is switched on */
#define GPS_OFF_VBAT 1000 /* Battery voltage threshold at which GPS is switched off */
#define TRACE_TIME TRUE /* Enables time tracing on debugging port */
#define TRACE_FILE TRUE /* Enables file and line tracing on debugging port */

Wyświetl plik

@ -312,7 +312,7 @@ static const struct regval_list ov2640_init_regs[] = {
{ 0x2e, 0xdf },
{ BANK_SEL, BANK_SEL_SENS },
{ 0x3c, 0x32 },
{ CLKRC, CLKRC_DIV_SET(3) },
{ CLKRC, CLKRC_DIV_SET(2) },
{ COM2, COM2_OCAP_Nx_SET(3) },
{ REG04, REG04_DEF | REG04_HREF_EN },
{ COM8, COM8_DEF | COM8_AGC_EN | COM8_AEC_EN | COM8_BNDF_EN },

Wyświetl plik

@ -17,9 +17,7 @@
#define FSV (40 - 40 / (DENO))
#define FSC ((FSR) / (PAC1720_RSENSE))
static int32_t pac1720_isol;
static int32_t pac1720_pbat;
static int32_t pac1720_isol_counter;
static int32_t pac1720_pbat_counter;
int16_t pac1720_getPbat(void) {
@ -29,7 +27,7 @@ int16_t pac1720_getPbat(void) {
if(I2C_read16(PAC1720_ADDRESS, PAC1720_CH2_PWR_RAT_HIGH, (uint16_t*)&val)) {
I2C_read8(PAC1720_ADDRESS, PAC1720_CH2_VSENSE_HIGH, &sign);
return (sign >> 7 ? 1 : -1) * (val * fsp / 65535);
return (sign >> 7 ? -1 : 1) * (val * fsp / 65535);
} else {
return 0; // PAC1720 not available (maybe Vcc too low)
}
@ -39,14 +37,14 @@ int16_t pac1720_getIsol(void) {
if(getUSBVoltageMV() < 300) // USB not connected
{
// Short solar cells
//palClearLine(LINE_SOL_SHORT_EN);
palClearLine(LINE_SOL_SHORT_EN);
chThdSleepMilliseconds(300); // Wait a little bit to measure a correct value
int16_t val;
uint8_t ret = I2C_read16(PAC1720_ADDRESS, PAC1720_CH1_VSENSE_HIGH, (uint16_t*)&val);
// Unshort solar cells
//palSetLine(LINE_SOL_SHORT_EN);
palSetLine(LINE_SOL_SHORT_EN);
// Calculate solar current
if(ret) {
@ -59,21 +57,6 @@ int16_t pac1720_getIsol(void) {
return 0; // USB connected (we dont want to short USB)
}
int16_t pac1720_getAvgIsol(void) {
// Return current value if time interval too short
if(!pac1720_isol_counter)
pac1720_getIsol();
// Calculate average power
int16_t ret = pac1720_isol / pac1720_isol_counter;
// Reset current measurement
pac1720_isol = 0;
pac1720_isol_counter = 0;
return ret;
}
int16_t pac1720_getAvgPbat(void) {
// Return current value if time interval too short
if(!pac1720_pbat_counter)
@ -118,17 +101,10 @@ THD_FUNCTION(pac1720_thd, arg)
{
(void)arg;
uint8_t cntr = 0;
while(true)
{
// Measure solar short current (if USB not connected)
if(!cntr++) {
pac1720_isol += pac1720_getIsol();
pac1720_isol_counter++;
}
// Measure battery power
pac1720_pbat -= pac1720_getPbat();
pac1720_pbat += pac1720_getPbat();
pac1720_pbat_counter++;
chThdSleepMilliseconds(50);

Wyświetl plik

@ -52,7 +52,6 @@
void pac1720_init(void);
int16_t pac1720_getIsol(void);
int16_t pac1720_getPbat(void);
int16_t pac1720_getAvgIsol(void);
int16_t pac1720_getAvgPbat(void);
uint16_t pac1720_getBatteryVoltage(void);
uint16_t pac1720_getSolarVoltage(void);

Wyświetl plik

@ -393,7 +393,7 @@ bool GPS_Init(void) {
void GPS_Deinit(void)
{
// Switch MOSFET
TRACE_INFO("GPS > Switch off");
palClearLine(LINE_GPS_EN);
//TRACE_INFO("GPS > Switch off");
//palClearLine(LINE_GPS_EN);
}

Wyświetl plik

@ -46,7 +46,7 @@
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLM_VALUE 26
#define STM32_PLLN_VALUE 192
#define STM32_PLLP_VALUE 4
#define STM32_PLLP_VALUE 2
#define STM32_PLLQ_VALUE 4
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV4
@ -54,7 +54,7 @@
#define STM32_RTCSEL STM32_RTCSEL_LSI
#define STM32_RTCPRE_VALUE 8
#define STM32_MCO1SEL STM32_MCO1SEL_HSE
#define STM32_MCO1PRE STM32_MCO1PRE_DIV4
#define STM32_MCO1PRE STM32_MCO1PRE_DIV2
#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
#define STM32_I2SSRC STM32_I2SSRC_CKIN

Wyświetl plik

@ -10,101 +10,124 @@
#include "modules.h"
#include "base.h"
#include "aprs.h"
#include <math.h>
#include "flash.h"
#include "watchdog.h"
static uint16_t pkt[16*3+2];
static uint8_t pkt_base91[BASE91LEN(sizeof(pkt))];
static uint32_t nextLogEntryCounter; // Current log pointer (determines next log transmission)
/*
* Sequence determines in which order log packets are sent out
* This sequence sorts all log messages in a way, that gaps in the log are
* equally distributed over the route, if not all packets could be received
* by the APRS network.
*/
static const uint16_t log_transmission_sequence[] = {
731,2148,407,645,1599,2319,2970,324,1489,2143,60,1269,463,1126,2302,2115,77,837,445,2180,2451,85,2465,413,2361,526,702,1768,475,916,507,1675,2429,1350,546,1516,1431,1793,2831,2958,
2176,2762,1009,1936,415,334,1780,1322,2754,965,2606,1790,2035,2203,276,750,501,1156,63,1424,438,1399,1854,1760,644,329,3023,2067,2463,2843,517,1453,490,319,2037,1542,2296,246,810,2895,
361,3070,520,2858,2237,498,2178,381,1400,1772,2834,1527,1634,1600,851,1993,1061,976,1859,2499,2459,2484,2100,336,1853,2634,2232,911,1240,2349,1121,370,1151,2482,944,1406,826,1656,741,2772,
2388,2748,591,3019,2228,1375,92,2290,1086,2411,2813,999,574,686,2698,649,84,1612,2512,283,690,354,518,1084,2885,2601,1693,132,33,2507,252,776,1705,1270,884,2756,938,988,748,1922,
1124,2215,2789,400,108,845,200,2666,444,2189,1587,1397,1680,216,1619,716,1012,2659,857,465,674,2887,551,1710,945,61,3065,2740,2556,377,2183,2235,3010,1687,1716,339,263,96,2799,694,
738,2502,1183,2316,1873,683,767,1178,2540,2526,2401,2510,2426,2504,1927,1485,1435,1255,2239,2663,1051,2284,245,2046,2117,2830,2880,1529,1801,1437,1961,1534,2509,1318,3038,700,129,1013,2345,2410,
2757,2527,2960,152,2704,1017,1559,568,1449,267,447,1452,2057,371,2676,1647,578,1947,1785,1229,2241,1907,455,2167,1691,842,1390,2696,2355,2992,1188,1053,3027,2181,858,2260,2359,2407,2518,2322,
561,2471,1888,1837,2776,2803,115,1519,1536,1501,17,576,1582,3063,2077,1484,2987,1414,1803,2982,2651,457,385,1547,2457,1428,1725,708,2820,948,1879,2983,2661,1157,360,2139,1378,1383,2897,433,
2959,1697,42,2917,1092,1825,2879,1407,337,917,1953,1110,1777,2771,2528,745,566,643,2536,194,1949,2741,294,28,2705,1058,2269,2562,1341,343,502,1396,557,2192,2450,768,2894,2814,2055,3011,
2876,23,2332,2662,1880,405,356,40,1792,1664,1943,2769,3025,723,2633,1189,3021,2580,239,3050,1429,303,459,2372,1050,489,2247,2134,2732,597,882,2702,1190,2901,2155,575,1332,443,506,1133,
1526,2193,2470,2888,1848,737,1440,1921,2103,2015,1865,167,618,1098,1670,724,1569,1627,172,2280,1741,2128,1135,416,1568,2922,2628,961,2185,1918,855,1808,2272,1906,982,2986,1973,523,1881,713,
2135,2087,2918,2483,1505,701,1804,1083,349,2142,124,227,2911,846,675,808,1033,802,705,2313,2182,2381,1731,2729,2083,967,321,1778,1685,1727,187,1500,1225,1461,1184,2036,1211,1115,3000,384,
1327,2695,1317,1148,1724,1016,806,732,374,2826,2520,1127,1475,1287,522,865,2767,1863,901,1007,2715,604,2523,1980,2890,3069,2782,613,1072,1118,2299,689,269,2995,1125,1340,687,1019,1591,796,
2554,380,224,1912,2306,101,435,2305,135,1325,484,1469,1089,2,820,619,2413,2298,784,2954,874,226,1026,2390,2364,511,8,71,2427,1412,1232,1480,977,1112,1079,586,155,481,2329,1374,
2195,2564,1610,139,1252,1744,3044,301,1847,843,1688,679,1776,1373,2976,2701,2607,2925,2013,1586,1316,1570,1871,2493,1583,2108,629,3005,2068,730,1631,1305,271,2442,2945,1153,2304,2805,867,2066,
1020,712,2861,2017,1324,2165,1528,1809,2875,2714,2969,3029,1117,630,2397,1018,1915,2336,382,1962,2753,261,3066,2516,1314,2218,1517,186,1005,1024,410,1042,83,1931,2075,207,1541,437,2334,2599,
524,1737,3034,2088,1457,2255,2282,606,2440,889,2727,1740,307,393,1187,1508,850,253,2941,46,614,2802,1165,2478,514,1254,39,1463,508,1827,369,2277,2550,2989,2801,673,2567,169,2436,2557,
1004,2202,2357,676,1828,3008,2794,1593,146,2008,292,1545,2877,2882,1377,4,2175,494,1023,2264,2962,1733,2351,1478,427,1411,2362,1035,2110,838,1575,2194,2821,317,1310,1703,2275,812,41,257,
2836,903,1223,2273,1260,1100,383,3013,195,2323,2817,1271,1678,1757,1289,2259,1944,2211,1551,1313,1523,1152,1581,1584,2097,1158,1366,2380,1892,1006,2972,627,794,2977,1617,2219,535,743,1566,1028,
2474,1864,612,206,1298,684,3028,2604,2916,3055,787,1783,1299,500,617,2352,759,885,2923,268,1543,2085,2681,1160,622,2884,282,1712,1108,1066,2752,2023,2832,158,1858,1762,2866,2806,2618,2996,
2119,2496,2586,1222,589,3058,2736,1730,482,2070,36,2220,254,2171,1512,2650,1353,2324,315,1022,2758,1308,2145,2559,1085,1782,1432,2274,1692,2734,1890,2855,140,2846,351,2369,3022,909,359,411,
2903,3047,50,1421,2217,707,2694,638,1351,2433,555,499,666,1641,2124,1504,1376,1978,1237,793,1224,592,2458,209,1487,540,1074,572,2473,2881,2674,1064,1988,2810,229,1093,2120,353,1021,2646,
2133,853,691,886,1574,1195,2548,2206,1810,1320,2850,1966,2216,1496,2990,2849,19,2785,2796,2531,171,2125,1797,1262,3024,1628,1292,943,1899,133,1713,1230,215,1937,1578,2472,2569,832,1784,436,
448,2041,2344,1094,2914,1372,232,2159,248,1389,505,1878,2953,2105,331,231,601,2793,840,1132,1256,291,760,1567,2867,651,868,859,854,1481,2224,265,1728,1764,2632,1090,264,757,1509,595,
1427,941,43,993,2602,2456,15,1749,1087,2644,1851,1839,1754,2034,816,1261,797,2138,2386,1648,2615,2619,663,388,119,2001,2927,163,210,1221,960,667,1682,365,2864,2697,1384,2626,2317,2915,
624,1884,1060,779,1274,1684,1027,2905,2102,2208,1312,3020,13,1992,811,1651,286,908,2044,958,1537,695,2931,401,1781,1615,3048,2809,1434,3033,2541,2783,1668,2051,2033,1336,2009,973,2151,1136,
2207,2402,823,1267,996,764,620,2022,2963,1191,2744,1395,2021,1216,2617,208,3031,1379,2221,580,1218,2863,783,1249,1284,1077,1202,1175,711,1275,449,190,1382,477,1447,2404,2652,2204,1138,2283,
2654,703,2173,2198,2309,1413,2711,528,530,2935,2671,1629,598,1671,773,2365,1700,1483,581,1796,0,964,1360,2245,786,2010,2773,1258,1032,780,704,1895,1055,728,144,914,2121,693,1630,1977,
2577,242,873,2321,2994,2004,1743,1758,1044,801,573,734,1940,1521,1996,1679,2032,594,1257,1775,1588,2675,2635,1059,1852,26,1248,247,872,880,395,2278,199,970,2966,2593,1846,1234,297,1417,
1002,1607,460,30,2816,875,2640,2400,1836,905,1715,1970,2434,640,665,1540,1337,1564,2869,1942,2575,52,871,512,181,1850,2005,2409,1909,1554,1494,3041,792,2543,2808,1065,422,2672,90,1726,
1908,1113,1824,1723,176,2449,2419,1530,1062,154,2109,2106,72,330,74,3042,824,1371,2585,616,492,2900,230,2587,2578,2177,2946,3052,2683,325,822,774,175,423,35,583,1265,564,1338,747,
1994,1507,1991,2595,1171,2366,758,2943,137,126,225,273,746,3037,1605,183,440,316,178,1342,1959,2394,496,588,2786,38,258,1876,635,1283,479,1246,1956,1418,64,2230,1676,1349,3043,2231,
1107,2144,751,930,2759,596,2187,2896,14,1789,2367,1495,290,2081,2906,259,1491,1179,2844,2061,266,2891,1573,1898,2252,2122,1531,1602,1116,626,1677,2094,929,924,335,2532,2647,2293,2079,414,
2494,432,211,34,262,2770,1149,992,117,2938,1914,2921,1841,3045,2147,660,2964,2058,1549,1822,402,2572,1477,1239,2281,1048,1698,2840,893,1807,740,1123,1721,223,2378,1345,1460,919,1164,2842,
1192,1596,2289,54,70,756,800,122,1515,1070,1738,1667,1355,387,1476,1367,2852,1637,2535,1159,2240,2624,3056,2383,2924,2684,1924,969,2141,2503,2712,2967,939,1319,1174,2414,462,883,355,2517,
180,654,1456,2678,2848,2291,2608,1354,2558,814,1952,2157,1464,770,3026,2955,877,900,754,1717,408,952,474,2213,1786,571,1368,468,971,2865,1170,968,1146,1941,1957,2561,2689,2981,184,1816,
652,2956,2811,1015,997,298,1752,1861,1105,1845,2930,478,112,818,251,3014,980,981,2405,458,417,1147,1652,896,2553,1933,1560,2600,2708,2062,972,2790,1444,1832,2310,338,1003,2074,1454,2288,
819,426,367,825,127,1935,1709,244,109,979,2737,633,398,1999,2857,2718,1594,111,255,219,1210,412,1635,431,1831,1910,2438,2521,1885,193,3039,3006,1546,2014,1506,2099,2295,1916,2460,2082,
237,322,2384,1982,1975,2847,715,1946,669,1660,2039,1213,1538,2060,2761,6,1331,2285,2779,2226,238,2570,2555,2152,847,1231,1470,910,2997,2766,1405,1244,2140,888,2579,1900,765,1891,1346,2132,
1770,1387,2854,2667,913,1416,1099,849,2637,2529,1646,1645,485,2999,1765,656,1767,2160,149,130,2268,1080,1067,634,1518,182,809,1142,1235,121,2824,3003,1415,2016,2780,2174,699,1268,2453,2872,
1948,1114,1965,2522,2150,1468,2700,1805,1095,2111,116,3071,466,803,1820,256,2534,2205,79,1938,534,2856,1654,305,607,1874,2645,2045,830,2692,2957,3049,1037,2660,65,156,1745,870,2391,1882,
1241,1843,587,7,2170,378,547,2605,2028,1386,2477,2508,2934,2030,95,2011,2447,1410,421,1655,1499,18,2314,2625,2420,2649,2950,582,88,1068,739,2225,1199,2018,429,907,313,1245,2387,986,
1902,113,2091,2653,2622,2104,2975,1109,1662,2524,222,1155,2439,749,1462,308,1196,2991,1057,2639,1193,2339,3002,2581,404,1040,2340,1897,118,2978,662,110,2886,869,2363,1467,1162,491,1838,1945,
608,288,2024,1701,2706,1842,1759,2685,1120,2909,454,68,364,1203,1939,672,189,487,1503,923,442,1344,2498,1963,3012,680,2984,1306,1167,2129,25,899,2965,311,533,392,2002,1934,2973,2423,
1286,1291,1756,1243,174,2481,1798,658,2214,3067,2566,2190,24,2398,2347,934,2126,2598,605,726,2095,2513,1580,228,2871,1347,1144,834,1896,1206,386,1226,2668,2665,318,906,2636,1130,2878,2399,
2123,469,2330,2670,2942,2723,302,2248,956,1862,1119,1989,441,621,1401,2179,2565,556,2337,2073,815,1525,105,2707,1172,2725,81,817,637,798,1227,2229,1544,2807,2944,2236,2212,2354,611,1173,
3040,1238,10,1276,1597,1928,1802,1364,2270,1609,2107,2186,2050,1394,420,280,927,1194,1097,123,1445,2590,2657,1917,1971,2519,1293,1129,537,2263,2441,49,1735,920,895,2395,2301,406,51,1614,
188,2648,439,935,2113,2851,1683,299,418,2627,1887,1563,554,863,1603,323,396,959,3057,2341,2003,2853,839,106,2739,1696,73,284,2467,2452,2379,2031,1323,2717,2389,66,1812,2682,1539,2907,
1561,1818,891,1576,2063,904,1181,1997,947,3061,950,1180,1694,2720,1497,1626,1840,1408,1045,1704,552,2629,1025,2370,2348,954,1465,150,1458,1613,2327,1835,1011,2279,250,2158,2373,2149,1620,1834,
2294,2491,372,706,513,1339,1532,62,2286,766,527,1708,2163,2114,12,2609,864,2201,861,1673,1139,1719,2444,2266,2870,2078,56,2222,2320,368,2261,718,1814,3068,990,312,1829,2196,1984,76,
3,2056,2161,1632,1747,358,2234,833,277,1359,1208,2688,1103,1913,1047,921,848,1979,285,214,2551,1930,1279,1639,260,2130,778,1672,1795,1729,1215,791,2537,827,1990,2136,93,2841,532,1302,
2751,390,1335,1763,2432,1823,2722,1166,1746,2716,2153,2253,1330,1381,1761,2054,560,2825,1034,1472,2462,1052,1315,717,2988,1533,1392,2845,1043,1779,2454,142,1333,2883,37,1844,1869,2573,1143,1633,
2920,2421,647,1358,2437,922,2874,1811,1653,221,170,2318,1611,2899,2742,733,2592,1955,3035,2833,671,541,1650,2071,2448,789,2486,710,590,1220,2827,1998,2515,2430,1236,994,1141,2902,1606,3030,
2162,1849,2168,27,529,1806,549,2792,2422,1266,1209,1176,451,1748,220,2443,516,1285,1556,918,1592,2968,2574,1985,1550,926,664,1253,807,352,1774,688,272,2620,2582,1742,593,9,887,3007,
1177,363,1282,2118,2726,989,1903,2932,2750,1356,998,1644,1642,1736,878,1690,1608,1555,2485,1259,1649,539,1278,134,761,1054,974,2116,1326,379,399,799,86,985,2638,650,932,287,1091,2815,
1815,391,1987,2374,984,1623,1663,2765,2080,3059,138,1404,143,1833,2396,57,1450,2787,678,1145,2656,162,2745,2755,1522,2940,828,2424,856,104,1493,736,3053,2828,2416,3017,78,1794,1008,646,
47,2131,862,1707,2949,785,1981,2064,1334,419,2797,1281,653,1622,1565,821,2455,347,1486,153,2643,1423,148,2312,2043,2052,300,67,141,11,397,2292,1128,1750,2784,2612,609,559,2687,623,
1894,434,2446,804,2641,2731,2238,2819,376,2603,1640,2242,2112,98,103,2506,2393,2560,2563,2487,2335,452,1926,2360,128,2059,151,639,320,114,44,2584,424,1134,2686,345,2308,2098,2777,2669,
281,1681,2721,2823,1082,1751,2331,2658,2631,2588,1905,2012,2093,1904,279,450,456,2311,1056,1773,425,536,2156,2868,2223,762,1950,1200,2936,3036,1479,1081,389,2812,446,2980,729,577,963,714,
1826,2703,1297,476,21,2710,1595,558,1380,2552,1010,191,1769,2258,293,218,160,2549,1535,1451,91,2859,933,902,1513,1182,1362,1625,2418,681,3001,2267,2713,236,725,2583,1964,1572,1388,1714,
890,603,2350,2699,2904,1088,2892,89,1598,2839,1821,1233,2948,2256,2743,2591,1030,1393,1616,289,2007,2343,2952,2415,1228,2403,1766,1046,204,928,599,1621,2818,2889,235,1974,2693,962,719,1311,
570,1420,2961,1385,3004,860,1441,636,29,744,2019,2673,1689,1446,2568,2209,1951,304,772,1791,987,2184,2974,1102,1866,428,898,274,2020,1078,2053,2613,1014,1666,202,166,177,58,879,2610,
1967,1552,548,333,1459,1466,1734,610,1510,205,2998,1161,2368,240,642,145,2461,2544,2382,735,2090,1272,1207,1471,1217,727,2188,3054,483,2417,1296,2730,775,881,1309,2300,1096,94,3016,2691,
493,1352,852,782,1788,1300,2084,1361,1870,32,2589,720,473,579,164,1433,1363,1041,192,1049,2227,1,2210,600,2346,2047,2303,2775,2172,173,2505,497,453,2026,692,503,1548,659,82,1168,
243,1819,1295,648,2408,509,955,2425,2679,2724,2200,2873,2069,430,1073,278,1101,470,409,295,1856,59,342,1343,2479,296,3009,1071,2076,1321,531,1739,876,2979,1972,813,1370,1868,1557,2338,
2492,1636,936,2233,1520,1490,2092,201,2086,2760,2680,2199,1425,2835,1039,777,1288,1960,1732,1348,1001,2042,2435,2246,1280,1618,1855,1857,2250,107,1643,120,1986,1277,2514,942,310,1201,3046,1303,
31,1140,213,2495,2476,897,1585,2747,1925,97,2838,2276,1502,1932,1787,2910,2377,2738,2664,1958,234,983,1911,1571,525,2908,366,698,2912,2469,1426,519,2297,2072,829,2571,2392,1601,2048,1893,
1706,951,48,2539,2985,1264,2781,781,1214,2778,1674,2353,125,99,2919,2325,1438,20,2249,1122,569,844,2545,931,2376,2480,2947,1250,87,3062,1106,1198,1402,866,1799,1273,2511,615,2191,1328,
2412,2326,1755,69,1524,348,544,1263,100,631,2530,697,769,1365,2597,159,1197,2709,2049,350,1205,2154,1702,45,545,1558,937,341,55,1137,2862,661,1877,2096,2146,1901,16,2315,2328,632,
953,1665,835,1659,212,602,755,2893,340,2655,2630,1919,2829,628,1000,2546,2728,1443,2764,543,925,836,668,1076,1695,1398,197,249,2025,1036,1492,131,2428,753,2431,1419,1579,2244,22,2375,
1111,521,2489,2475,2735,771,2763,1590,2406,1817,2029,2614,461,709,1624,2466,1430,2040,2837,2937,752,995,966,2677,894,2623,721,3064,2197,2576,1436,1063,1422,2719,165,2342,241,2243,196,892,
1983,471,157,327,2385,2006,2596,677,394,2497,2538,685,2800,504,1875,655,2127,795,1439,562,136,722,147,1589,1657,2490,1473,1069,1442,2939,1718,1860,1830,80,550,912,1969,2926,1883,488,
1638,790,2287,1186,2169,1185,1290,75,2804,2616,1304,3060,314,346,1686,344,946,1498,1482,1929,2464,940,2898,357,1669,1889,1920,1722,1604,198,538,2356,2768,2257,2358,2913,2798,2271,2788,328,
1409,515,2101,2501,1872,1104,788,2795,1488,1813,657,203,2533,2542,2307,1954,2690,625,1553,542,1029,1658,670,472,233,1075,510,2525,1711,915,1511,309,362,467,2000,2929,2251,1923,161,1031,
375,805,841,1307,2137,464,1514,2611,2860,270,1150,641,2027,1474,553,585,1251,2594,102,2749,53,563,1968,3015,991,306,1699,495,957,1369,480,696,2468,2065,373,1577,3051,2333,1771,2621,
3018,567,978,2642,2265,1448,1294,332,1995,742,1976,2993,1867,168,2445,2822,2038,217,1131,565,1391,1163,2166,2733,2164,2371,1720,2971,1212,1247,763,1204,1753,949,2791,2951,2774,1357,1154,2547,
1800,2500,2488,185,831,1329,3032,2933,1301,2746,2089,682,1169,326,584,2262,1661,403,1886,975,486,1219,275,2254,179,1455,1242,5,2928,1562,1403,1038
};
uint16_t log_transmission_sequence_cntr = 0;
/**
* Lookup table of NL for the CPR algorithm
* See ICAO DO-260B for more details
*/
uint8_t lookupNL(double lat)
void getNextLogTrackPoint(trackPoint_t* log)
{
// FIXME: Change this mess to a real lookup table
double a = fabs(lat);
if (a < 10.47047130) return 59;
else if(a < 14.82817437) return 58;
else if(a < 18.18626357) return 57;
else if(a < 21.02939493) return 56;
else if(a < 23.54504487) return 55;
else if(a < 25.82924707) return 54;
else if(a < 27.93898710) return 53;
else if(a < 29.91135686) return 52;
else if(a < 31.77209708) return 51;
else if(a < 33.53993436) return 50;
else if(a < 35.22899598) return 49;
else if(a < 36.85025108) return 48;
else if(a < 38.41241892) return 47;
else if(a < 39.92256684) return 46;
else if(a < 41.38651832) return 45;
else if(a < 42.80914012) return 44;
else if(a < 44.19454951) return 43;
else if(a < 45.54626723) return 42;
else if(a < 46.86733252) return 41;
else if(a < 48.16039128) return 40;
else if(a < 49.42776439) return 39;
else if(a < 50.67150166) return 38;
else if(a < 51.89342469) return 37;
else if(a < 53.09516153) return 36;
else if(a < 54.27817472) return 35;
else if(a < 55.44378444) return 34;
else if(a < 56.59318756) return 33;
else if(a < 57.72747354) return 31;
else if(a < 58.84763776) return 30;
else if(a < 59.95459277) return 30;
else if(a < 61.04917774) return 29;
else if(a < 62.13216659) return 28;
else if(a < 63.20427479) return 27;
else if(a < 64.26616523) return 26;
else if(a < 65.31845310) return 25;
else if(a < 66.36171008) return 24;
else if(a < 67.39646774) return 23;
else if(a < 68.42322022) return 22;
else if(a < 69.44242631) return 21;
else if(a < 70.45451075) return 20;
else if(a < 71.45986473) return 19;
else if(a < 72.45884545) return 18;
else if(a < 73.45177442) return 17;
else if(a < 74.43893416) return 16;
else if(a < 75.42056257) return 15;
else if(a < 76.39684391) return 14;
else if(a < 77.36789461) return 13;
else if(a < 78.33374083) return 12;
else if(a < 79.29428225) return 11;
else if(a < 80.24923213) return 10;
else if(a < 81.19801349) return 9;
else if(a < 82.13956981) return 8;
else if(a < 83.07199445) return 7;
else if(a < 83.99173563) return 6;
else if(a < 84.89166191) return 5;
else if(a < 85.75541621) return 4;
else if(a < 86.53536998) return 3;
else if(a < 87.00000000) return 2;
else return 1;
}
// Determine sector
uint32_t address = LOG_FLASH_ADDR1;
uint32_t i = 0;
do {
// Determine which log has to be sent
uint16_t log_id = log_transmission_sequence[log_transmission_sequence_cntr];
/**
* Compressed position reporting format encoding
* CPR Parameters nz=60, nb=8, na=360
* See ICAO DO-260B for more details
*/
uint16_t cpr_encode(bool cprFormat, double lat, double lon)
{
// Convert coordinates
if(lat < 0)
lat += 360; // Southern hemisphere is shown as 270-360 degree
// Determine sector and address
if(log_id < LOG_SECTOR_SIZE/sizeof(trackPoint_t)) { // Flash sector 10
address = LOG_FLASH_ADDR1 + log_id * sizeof(trackPoint_t);
} else { // Flash sector 11
address = LOG_FLASH_ADDR2 + log_id * sizeof(trackPoint_t) - LOG_SECTOR_SIZE;
}
double dlat[] = {6.0, 360.0/59.0};
uint8_t yz = floor(256 * fmod(lat, dlat[cprFormat]) / dlat[cprFormat] + 0.5);
double rlat = dlat[cprFormat] * (yz / 256 + floor(lat / dlat[cprFormat]));
uint8_t nl = lookupNL(rlat);
double dlon = nl-cprFormat > 0 ? 360.0 / (nl-cprFormat) : 360.0;
uint8_t xz = floor(256 * fmod(lon, dlon) / dlon + 0.5);
return (yz << 8) | xz;
// Increment sequence counter
log_transmission_sequence_cntr = (log_transmission_sequence_cntr+1) % (sizeof(log_transmission_sequence) / sizeof(uint16_t));
// Read data from memory
flashRead(address, (char*)log, sizeof(trackPoint_t));
/* While the sequence has more values than the log has logs, we check if we
* are inside the log-address-range. The Sequence has more IDs because it
* would be possible to decrease sizeof(trackPoint_t) and then more Ids
* would be needed.
*/
} while((address > LOG_FLASH_ADDR2+LOG_SECTOR_SIZE || log->id == 0xFFFFFFFF) && i++ < sizeof(log_transmission_sequence) / sizeof(uint16_t));
}
THD_FUNCTION(logThread, arg)
@ -120,34 +143,26 @@ THD_FUNCTION(logThread, arg)
if(!p_sleep(&conf->sleep_conf))
{
// Get log from memory
trackPoint_t log;
//getLogTrackPoints(&log, nextLogEntryCounter++, 1);
// Encode absolute time
//pkt[0] = log.time >> 16;
//pkt[1] = log.time & 0xFFFF;
uint32_t rel_time;
uint16_t pkt[64]; // 16 PositionPoints each 10 bytes
uint8_t pkt_base91[BASE91LEN(128)];
for(uint16_t t=0; t<sizeof(pkt_base91); t++) pkt_base91[t] = 0; // Deleting buffer
// Encode log points
for(uint32_t i=0,z=0; i<16; i++,z++)
TRACE_INFO("LOG > Encode 16 log points")
for(uint8_t i=0; i<16; i++)
{
//getLogTrackPoints(&log, nextLogEntryCounter++, 1); // Read log point
trackPoint_t log;
getNextLogTrackPoint(&log);
//if(z == LOG_FLASH_SIZE / sizeof(trackPoint_t)) // No entry in log memory
// break;
TRACE_INFO("date=%02d.%02d. time=%02d:%02d lat=%d lon=%d alt=%d", log.time.day, log.time.month, log.time.hour, log.time.minute, log.gps_lat, log.gps_lon, log.gps_alt);
//if(log.time == 0xFFFFFFFF) { // Log entry invalid (not set)
// i--;
// continue;
//}
pkt[i*4+0] = (log.time.minute/10) + (6*log.time.hour) + (144*(log.time.day-1)) + (4464*(log.time.month-1)); // Time/Date of year (1 = 5min, all monthes have 31days, day and month starts at 0)
pkt[i*4+1] = (((uint64_t)((uint64_t)log.gps_lat + 900000000)) * 65535) / 1800000000; // Latitude (get full 16bit resolution over 180°)
pkt[i*4+2] = (((uint64_t)((uint64_t)log.gps_lon + 1800000000)) * 65535) / 3600000000; // Longitude (get full 16bit resolution over 360°)
pkt[i*4+3] = log.gps_alt; // Altitude in meters (cut off first two MSB bytes)
//TRACE_INFO("LOG > Encode log ID=%d", (nextLogEntryCounter-1) % (LOG_FLASH_SIZE / sizeof(trackPoint_t)));
//pkt[i*3+2] = log.time - rel_time; // Time difference to last log point
//pkt[i*3+3] = cpr_encode(i%2, log.gps_lat/10000000.0, log.gps_lon/10000000.0);
//pkt[i*3+4] = log.gps_alt; // Altitude in meters
//rel_time = log.time; // Set absolute time for next log point
TRACE_INFO("%04x %04x %04x %04x", pkt[i*4+0], pkt[i*4+1], pkt[i*4+2], pkt[i*4+3]);
}
// Encode radio message
@ -162,14 +177,10 @@ THD_FUNCTION(logThread, arg)
msg.afsk_conf = &(conf->afsk_conf);
msg.gfsk_conf = &(conf->gfsk_conf);
// Deleting buffer
for(uint16_t t=0; t<sizeof(pkt_base91); t++)
pkt_base91[t] = 0;
base91_encode((uint8_t*)pkt, pkt_base91, sizeof(pkt)); // Encode base 91
msg.bin_len = aprs_encode_experimental('L', msg.msg, msg.mod, &conf->aprs_conf, pkt_base91, strlen((char*)pkt_base91)); // Encode APRS
base91_encode((uint8_t*)pkt, pkt_base91, sizeof(pkt));
msg.bin_len = aprs_encode_message(msg.msg, msg.mod, &conf->aprs_conf, APRS_DEST_CALLSIGN, (char*)pkt_base91);
transmitOnRadio(&msg, true);
transmitOnRadio(&msg, true); // Transmit packet
break;
default:

Wyświetl plik

@ -17,170 +17,6 @@ static trackPoint_t* lastTrackPoint;
static systime_t nextLogEntryTimer;
static module_conf_t trac_conf = {.name = "TRAC"}; // Fake config needed for watchdog tracking
/*
* Sequence determines in which order log packets are sent out
* This sequence sorts all log messages in a way, that gaps in the log are
* equally distributed over the route, if not all packets could be received
* by the APRS network.
*/
static const uint16_t log_transmission_sequence[] = {
731,2148,407,645,1599,2319,2970,324,1489,2143,60,1269,463,1126,2302,2115,77,837,445,2180,
2451,85,2465,413,2361,526,702,1768,475,916,507,1675,2429,1350,546,1516,1431,1793,2831,2958,
2176,2762,1009,1936,415,334,1780,1322,2754,965,2606,1790,2035,2203,276,750,501,1156,63,1424,
438,1399,1854,1760,644,329,3023,2067,2463,2843,517,1453,490,319,2037,1542,2296,246,810,2895,
361,3070,520,2858,2237,498,2178,381,1400,1772,2834,1527,1634,1600,851,1993,1061,976,1859,2499,
2459,2484,2100,336,1853,2634,2232,911,1240,2349,1121,370,1151,2482,944,1406,826,1656,741,2772,
2388,2748,591,3019,2228,1375,92,2290,1086,2411,2813,999,574,686,2698,649,84,1612,2512,283,
690,354,518,1084,2885,2601,1693,132,33,2507,252,776,1705,1270,884,2756,938,988,748,1922,
1124,2215,2789,400,108,845,200,2666,444,2189,1587,1397,1680,216,1619,716,1012,2659,857,465,
674,2887,551,1710,945,61,3065,2740,2556,377,2183,2235,3010,1687,1716,339,263,96,2799,694,
738,2502,1183,2316,1873,683,767,1178,2540,2526,2401,2510,2426,2504,1927,1485,1435,1255,2239,2663,
1051,2284,245,2046,2117,2830,2880,1529,1801,1437,1961,1534,2509,1318,3038,700,129,1013,2345,2410,
2757,2527,2960,152,2704,1017,1559,568,1449,267,447,1452,2057,371,2676,1647,578,1947,1785,1229,
2241,1907,455,2167,1691,842,1390,2696,2355,2992,1188,1053,3027,2181,858,2260,2359,2407,2518,2322,
561,2471,1888,1837,2776,2803,115,1519,1536,1501,17,576,1582,3063,2077,1484,2987,1414,1803,2982,
2651,457,385,1547,2457,1428,1725,708,2820,948,1879,2983,2661,1157,360,2139,1378,1383,2897,433,
2959,1697,42,2917,1092,1825,2879,1407,337,917,1953,1110,1777,2771,2528,745,566,643,2536,194,
1949,2741,294,28,2705,1058,2269,2562,1341,343,502,1396,557,2192,2450,768,2894,2814,2055,3011,
2876,23,2332,2662,1880,405,356,40,1792,1664,1943,2769,3025,723,2633,1189,3021,2580,239,3050,
1429,303,459,2372,1050,489,2247,2134,2732,597,882,2702,1190,2901,2155,575,1332,443,506,1133,
1526,2193,2470,2888,1848,737,1440,1921,2103,2015,1865,167,618,1098,1670,724,1569,1627,172,2280,
1741,2128,1135,416,1568,2922,2628,961,2185,1918,855,1808,2272,1906,982,2986,1973,523,1881,713,
2135,2087,2918,2483,1505,701,1804,1083,349,2142,124,227,2911,846,675,808,1033,802,705,2313,
2182,2381,1731,2729,2083,967,321,1778,1685,1727,187,1500,1225,1461,1184,2036,1211,1115,3000,384,
1327,2695,1317,1148,1724,1016,806,732,374,2826,2520,1127,1475,1287,522,865,2767,1863,901,1007,
2715,604,2523,1980,2890,3069,2782,613,1072,1118,2299,689,269,2995,1125,1340,687,1019,1591,796,
2554,380,224,1912,2306,101,435,2305,135,1325,484,1469,1089,2,820,619,2413,2298,784,2954,
874,226,1026,2390,2364,511,8,71,2427,1412,1232,1480,977,1112,1079,586,155,481,2329,1374,
2195,2564,1610,139,1252,1744,3044,301,1847,843,1688,679,1776,1373,2976,2701,2607,2925,2013,1586,
1316,1570,1871,2493,1583,2108,629,3005,2068,730,1631,1305,271,2442,2945,1153,2304,2805,867,2066,
1020,712,2861,2017,1324,2165,1528,1809,2875,2714,2969,3029,1117,630,2397,1018,1915,2336,382,1962,
2753,261,3066,2516,1314,2218,1517,186,1005,1024,410,1042,83,1931,2075,207,1541,437,2334,2599,
524,1737,3034,2088,1457,2255,2282,606,2440,889,2727,1740,307,393,1187,1508,850,253,2941,46,
614,2802,1165,2478,514,1254,39,1463,508,1827,369,2277,2550,2989,2801,673,2567,169,2436,2557,
1004,2202,2357,676,1828,3008,2794,1593,146,2008,292,1545,2877,2882,1377,4,2175,494,1023,2264,
2962,1733,2351,1478,427,1411,2362,1035,2110,838,1575,2194,2821,317,1310,1703,2275,812,41,257,
2836,903,1223,2273,1260,1100,383,3013,195,2323,2817,1271,1678,1757,1289,2259,1944,2211,1551,1313,
1523,1152,1581,1584,2097,1158,1366,2380,1892,1006,2972,627,794,2977,1617,2219,535,743,1566,1028,
2474,1864,612,206,1298,684,3028,2604,2916,3055,787,1783,1299,500,617,2352,759,885,2923,268,
1543,2085,2681,1160,622,2884,282,1712,1108,1066,2752,2023,2832,158,1858,1762,2866,2806,2618,2996,
2119,2496,2586,1222,589,3058,2736,1730,482,2070,36,2220,254,2171,1512,2650,1353,2324,315,1022,
2758,1308,2145,2559,1085,1782,1432,2274,1692,2734,1890,2855,140,2846,351,2369,3022,909,359,411,
2903,3047,50,1421,2217,707,2694,638,1351,2433,555,499,666,1641,2124,1504,1376,1978,1237,793,
1224,592,2458,209,1487,540,1074,572,2473,2881,2674,1064,1988,2810,229,1093,2120,353,1021,2646,
2133,853,691,886,1574,1195,2548,2206,1810,1320,2850,1966,2216,1496,2990,2849,19,2785,2796,2531,
171,2125,1797,1262,3024,1628,1292,943,1899,133,1713,1230,215,1937,1578,2472,2569,832,1784,436,
448,2041,2344,1094,2914,1372,232,2159,248,1389,505,1878,2953,2105,331,231,601,2793,840,1132,
1256,291,760,1567,2867,651,868,859,854,1481,2224,265,1728,1764,2632,1090,264,757,1509,595,
1427,941,43,993,2602,2456,15,1749,1087,2644,1851,1839,1754,2034,816,1261,797,2138,2386,1648,
2615,2619,663,388,119,2001,2927,163,210,1221,960,667,1682,365,2864,2697,1384,2626,2317,2915,
624,1884,1060,779,1274,1684,1027,2905,2102,2208,1312,3020,13,1992,811,1651,286,908,2044,958,
1537,695,2931,401,1781,1615,3048,2809,1434,3033,2541,2783,1668,2051,2033,1336,2009,973,2151,1136,
2207,2402,823,1267,996,764,620,2022,2963,1191,2744,1395,2021,1216,2617,208,3031,1379,2221,580,
1218,2863,783,1249,1284,1077,1202,1175,711,1275,449,190,1382,477,1447,2404,2652,2204,1138,2283,
2654,703,2173,2198,2309,1413,2711,528,530,2935,2671,1629,598,1671,773,2365,1700,1483,581,1796,
0,964,1360,2245,786,2010,2773,1258,1032,780,704,1895,1055,728,144,914,2121,693,1630,1977,
2577,242,873,2321,2994,2004,1743,1758,1044,801,573,734,1940,1521,1996,1679,2032,594,1257,1775,
1588,2675,2635,1059,1852,26,1248,247,872,880,395,2278,199,970,2966,2593,1846,1234,297,1417,
1002,1607,460,30,2816,875,2640,2400,1836,905,1715,1970,2434,640,665,1540,1337,1564,2869,1942,
2575,52,871,512,181,1850,2005,2409,1909,1554,1494,3041,792,2543,2808,1065,422,2672,90,1726,
1908,1113,1824,1723,176,2449,2419,1530,1062,154,2109,2106,72,330,74,3042,824,1371,2585,616,
492,2900,230,2587,2578,2177,2946,3052,2683,325,822,774,175,423,35,583,1265,564,1338,747,
1994,1507,1991,2595,1171,2366,758,2943,137,126,225,273,746,3037,1605,183,440,316,178,1342,
1959,2394,496,588,2786,38,258,1876,635,1283,479,1246,1956,1418,64,2230,1676,1349,3043,2231,
1107,2144,751,930,2759,596,2187,2896,14,1789,2367,1495,290,2081,2906,259,1491,1179,2844,2061,
266,2891,1573,1898,2252,2122,1531,1602,1116,626,1677,2094,929,924,335,2532,2647,2293,2079,414,
2494,432,211,34,262,2770,1149,992,117,2938,1914,2921,1841,3045,2147,660,2964,2058,1549,1822,
402,2572,1477,1239,2281,1048,1698,2840,893,1807,740,1123,1721,223,2378,1345,1460,919,1164,2842,
1192,1596,2289,54,70,756,800,122,1515,1070,1738,1667,1355,387,1476,1367,2852,1637,2535,1159,
2240,2624,3056,2383,2924,2684,1924,969,2141,2503,2712,2967,939,1319,1174,2414,462,883,355,2517,
180,654,1456,2678,2848,2291,2608,1354,2558,814,1952,2157,1464,770,3026,2955,877,900,754,1717,
408,952,474,2213,1786,571,1368,468,971,2865,1170,968,1146,1941,1957,2561,2689,2981,184,1816,
652,2956,2811,1015,997,298,1752,1861,1105,1845,2930,478,112,818,251,3014,980,981,2405,458,
417,1147,1652,896,2553,1933,1560,2600,2708,2062,972,2790,1444,1832,2310,338,1003,2074,1454,2288,
819,426,367,825,127,1935,1709,244,109,979,2737,633,398,1999,2857,2718,1594,111,255,219,
1210,412,1635,431,1831,1910,2438,2521,1885,193,3039,3006,1546,2014,1506,2099,2295,1916,2460,2082,
237,322,2384,1982,1975,2847,715,1946,669,1660,2039,1213,1538,2060,2761,6,1331,2285,2779,2226,
238,2570,2555,2152,847,1231,1470,910,2997,2766,1405,1244,2140,888,2579,1900,765,1891,1346,2132,
1770,1387,2854,2667,913,1416,1099,849,2637,2529,1646,1645,485,2999,1765,656,1767,2160,149,130,
2268,1080,1067,634,1518,182,809,1142,1235,121,2824,3003,1415,2016,2780,2174,699,1268,2453,2872,
1948,1114,1965,2522,2150,1468,2700,1805,1095,2111,116,3071,466,803,1820,256,2534,2205,79,1938,
534,2856,1654,305,607,1874,2645,2045,830,2692,2957,3049,1037,2660,65,156,1745,870,2391,1882,
1241,1843,587,7,2170,378,547,2605,2028,1386,2477,2508,2934,2030,95,2011,2447,1410,421,1655,
1499,18,2314,2625,2420,2649,2950,582,88,1068,739,2225,1199,2018,429,907,313,1245,2387,986,
1902,113,2091,2653,2622,2104,2975,1109,1662,2524,222,1155,2439,749,1462,308,1196,2991,1057,2639,
1193,2339,3002,2581,404,1040,2340,1897,118,2978,662,110,2886,869,2363,1467,1162,491,1838,1945,
608,288,2024,1701,2706,1842,1759,2685,1120,2909,454,68,364,1203,1939,672,189,487,1503,923,
442,1344,2498,1963,3012,680,2984,1306,1167,2129,25,899,2965,311,533,392,2002,1934,2973,2423,
1286,1291,1756,1243,174,2481,1798,658,2214,3067,2566,2190,24,2398,2347,934,2126,2598,605,726,
2095,2513,1580,228,2871,1347,1144,834,1896,1206,386,1226,2668,2665,318,906,2636,1130,2878,2399,
2123,469,2330,2670,2942,2723,302,2248,956,1862,1119,1989,441,621,1401,2179,2565,556,2337,2073,
815,1525,105,2707,1172,2725,81,817,637,798,1227,2229,1544,2807,2944,2236,2212,2354,611,1173,
3040,1238,10,1276,1597,1928,1802,1364,2270,1609,2107,2186,2050,1394,420,280,927,1194,1097,123,
1445,2590,2657,1917,1971,2519,1293,1129,537,2263,2441,49,1735,920,895,2395,2301,406,51,1614,
188,2648,439,935,2113,2851,1683,299,418,2627,1887,1563,554,863,1603,323,396,959,3057,2341,
2003,2853,839,106,2739,1696,73,284,2467,2452,2379,2031,1323,2717,2389,66,1812,2682,1539,2907,
1561,1818,891,1576,2063,904,1181,1997,947,3061,950,1180,1694,2720,1497,1626,1840,1408,1045,1704,
552,2629,1025,2370,2348,954,1465,150,1458,1613,2327,1835,1011,2279,250,2158,2373,2149,1620,1834,
2294,2491,372,706,513,1339,1532,62,2286,766,527,1708,2163,2114,12,2609,864,2201,861,1673,
1139,1719,2444,2266,2870,2078,56,2222,2320,368,2261,718,1814,3068,990,312,1829,2196,1984,76,
3,2056,2161,1632,1747,358,2234,833,277,1359,1208,2688,1103,1913,1047,921,848,1979,285,214,
2551,1930,1279,1639,260,2130,778,1672,1795,1729,1215,791,2537,827,1990,2136,93,2841,532,1302,
2751,390,1335,1763,2432,1823,2722,1166,1746,2716,2153,2253,1330,1381,1761,2054,560,2825,1034,1472,
2462,1052,1315,717,2988,1533,1392,2845,1043,1779,2454,142,1333,2883,37,1844,1869,2573,1143,1633,
2920,2421,647,1358,2437,922,2874,1811,1653,221,170,2318,1611,2899,2742,733,2592,1955,3035,2833,
671,541,1650,2071,2448,789,2486,710,590,1220,2827,1998,2515,2430,1236,994,1141,2902,1606,3030,
2162,1849,2168,27,529,1806,549,2792,2422,1266,1209,1176,451,1748,220,2443,516,1285,1556,918,
1592,2968,2574,1985,1550,926,664,1253,807,352,1774,688,272,2620,2582,1742,593,9,887,3007,
1177,363,1282,2118,2726,989,1903,2932,2750,1356,998,1644,1642,1736,878,1690,1608,1555,2485,1259,
1649,539,1278,134,761,1054,974,2116,1326,379,399,799,86,985,2638,650,932,287,1091,2815,
1815,391,1987,2374,984,1623,1663,2765,2080,3059,138,1404,143,1833,2396,57,1450,2787,678,1145,
2656,162,2745,2755,1522,2940,828,2424,856,104,1493,736,3053,2828,2416,3017,78,1794,1008,646,
47,2131,862,1707,2949,785,1981,2064,1334,419,2797,1281,653,1622,1565,821,2455,347,1486,153,
2643,1423,148,2312,2043,2052,300,67,141,11,397,2292,1128,1750,2784,2612,609,559,2687,623,
1894,434,2446,804,2641,2731,2238,2819,376,2603,1640,2242,2112,98,103,2506,2393,2560,2563,2487,
2335,452,1926,2360,128,2059,151,639,320,114,44,2584,424,1134,2686,345,2308,2098,2777,2669,
281,1681,2721,2823,1082,1751,2331,2658,2631,2588,1905,2012,2093,1904,279,450,456,2311,1056,1773,
425,536,2156,2868,2223,762,1950,1200,2936,3036,1479,1081,389,2812,446,2980,729,577,963,714,
1826,2703,1297,476,21,2710,1595,558,1380,2552,1010,191,1769,2258,293,218,160,2549,1535,1451,
91,2859,933,902,1513,1182,1362,1625,2418,681,3001,2267,2713,236,725,2583,1964,1572,1388,1714,
890,603,2350,2699,2904,1088,2892,89,1598,2839,1821,1233,2948,2256,2743,2591,1030,1393,1616,289,
2007,2343,2952,2415,1228,2403,1766,1046,204,928,599,1621,2818,2889,235,1974,2693,962,719,1311,
570,1420,2961,1385,3004,860,1441,636,29,744,2019,2673,1689,1446,2568,2209,1951,304,772,1791,
987,2184,2974,1102,1866,428,898,274,2020,1078,2053,2613,1014,1666,202,166,177,58,879,2610,
1967,1552,548,333,1459,1466,1734,610,1510,205,2998,1161,2368,240,642,145,2461,2544,2382,735,
2090,1272,1207,1471,1217,727,2188,3054,483,2417,1296,2730,775,881,1309,2300,1096,94,3016,2691,
493,1352,852,782,1788,1300,2084,1361,1870,32,2589,720,473,579,164,1433,1363,1041,192,1049,
2227,1,2210,600,2346,2047,2303,2775,2172,173,2505,497,453,2026,692,503,1548,659,82,1168,
243,1819,1295,648,2408,509,955,2425,2679,2724,2200,2873,2069,430,1073,278,1101,470,409,295,
1856,59,342,1343,2479,296,3009,1071,2076,1321,531,1739,876,2979,1972,813,1370,1868,1557,2338,
2492,1636,936,2233,1520,1490,2092,201,2086,2760,2680,2199,1425,2835,1039,777,1288,1960,1732,1348,
1001,2042,2435,2246,1280,1618,1855,1857,2250,107,1643,120,1986,1277,2514,942,310,1201,3046,1303,
31,1140,213,2495,2476,897,1585,2747,1925,97,2838,2276,1502,1932,1787,2910,2377,2738,2664,1958,
234,983,1911,1571,525,2908,366,698,2912,2469,1426,519,2297,2072,829,2571,2392,1601,2048,1893,
1706,951,48,2539,2985,1264,2781,781,1214,2778,1674,2353,125,99,2919,2325,1438,20,2249,1122,
569,844,2545,931,2376,2480,2947,1250,87,3062,1106,1198,1402,866,1799,1273,2511,615,2191,1328,
2412,2326,1755,69,1524,348,544,1263,100,631,2530,697,769,1365,2597,159,1197,2709,2049,350,
1205,2154,1702,45,545,1558,937,341,55,1137,2862,661,1877,2096,2146,1901,16,2315,2328,632,
953,1665,835,1659,212,602,755,2893,340,2655,2630,1919,2829,628,1000,2546,2728,1443,2764,543,
925,836,668,1076,1695,1398,197,249,2025,1036,1492,131,2428,753,2431,1419,1579,2244,22,2375,
1111,521,2489,2475,2735,771,2763,1590,2406,1817,2029,2614,461,709,1624,2466,1430,2040,2837,2937,
752,995,966,2677,894,2623,721,3064,2197,2576,1436,1063,1422,2719,165,2342,241,2243,196,892,
1983,471,157,327,2385,2006,2596,677,394,2497,2538,685,2800,504,1875,655,2127,795,1439,562,
136,722,147,1589,1657,2490,1473,1069,1442,2939,1718,1860,1830,80,550,912,1969,2926,1883,488,
1638,790,2287,1186,2169,1185,1290,75,2804,2616,1304,3060,314,346,1686,344,946,1498,1482,1929,
2464,940,2898,357,1669,1889,1920,1722,1604,198,538,2356,2768,2257,2358,2913,2798,2271,2788,328,
1409,515,2101,2501,1872,1104,788,2795,1488,1813,657,203,2533,2542,2307,1954,2690,625,1553,542,
1029,1658,670,472,233,1075,510,2525,1711,915,1511,309,362,467,2000,2929,2251,1923,161,1031,
375,805,841,1307,2137,464,1514,2611,2860,270,1150,641,2027,1474,553,585,1251,2594,102,2749,
53,563,1968,3015,991,306,1699,495,957,1369,480,696,2468,2065,373,1577,3051,2333,1771,2621,
3018,567,978,2642,2265,1448,1294,332,1995,742,1976,2993,1867,168,2445,2822,2038,217,1131,565,
1391,1163,2166,2733,2164,2371,1720,2971,1212,1247,763,1204,1753,949,2791,2951,2774,1357,1154,2547,
1800,2500,2488,185,831,1329,3032,2933,1301,2746,2089,682,1169,326,584,2262,1661,403,1886,975,
486,1219,275,2254,179,1455,1242,5,2928,1562,1403,1038
};
uint16_t log_transmission_sequence_cntr = 0;
/**
* Returns most recent track point witch is complete.
*/
@ -189,35 +25,6 @@ trackPoint_t* getLastTrackPoint(void)
return lastTrackPoint;
}
void getNextLogTrackPoint(trackPoint_t* log)
{
// Determine sector
uint32_t address;
do {
// Determine which log has to be sent
uint16_t log_id = log_transmission_sequence[log_transmission_sequence_cntr];
// Determine sector and address
if(log_id < LOG_SECTOR_SIZE/sizeof(trackPoint_t)) { // Flash sector 10
address = LOG_FLASH_ADDR1 + log_id * sizeof(trackPoint_t);
} else { // Flash sector 11
address = LOG_FLASH_ADDR2 + log_id * sizeof(trackPoint_t) - LOG_SECTOR_SIZE;
}
// Increment sequence counter
log_transmission_sequence_cntr = (log_transmission_sequence_cntr+1) % (sizeof(log_transmission_sequence) / sizeof(uint16_t));
/* While the sequence has more values than the log has logs, we check if we
* are inside the log-address-range. The Sequence has more IDs because it
* would be possible to decrease sizeof(trackPoint_t) and then more Ids
* would be needed.
*/
} while(address > LOG_FLASH_ADDR2+LOG_SECTOR_SIZE);
// Read data from memory
flashRead(address, (char*)log, sizeof(trackPoint_t));
}
/**
* Returns next free log entry address in memory. Returns 0 if all cells are
* filled with data
@ -261,7 +68,7 @@ static bool getLastLog(trackPoint_t* last)
if(pt.id != 0xFFFFFFFF && pt.id >= last_id) {
last_address = address;
last_id = pt.id;
}
} else TRACE_DEBUG("id=%d", pt.id);
}
// Search in flash sector 11
@ -272,7 +79,7 @@ static bool getLastLog(trackPoint_t* last)
if(pt.id != 0xFFFFFFFF && pt.id >= last_id) {
last_address = address;
last_id = pt.id;
}
} else TRACE_DEBUG("id=%d", pt.id);
}
if(last_address) {
@ -497,7 +304,7 @@ THD_FUNCTION(trackingThread, arg) {
tp->adc_vsol = getSolarVoltageMV();
tp->adc_vbat = getBatteryVoltageMV();
tp->adc_vusb = getUSBVoltageMV();
tp->adc_isol = pac1720_getAvgIsol();
tp->adc_isol = pac1720_getIsol();
tp->adc_pbat = pac1720_getAvgPbat();
bme280_t bme280;

Wyświetl plik

@ -5,10 +5,6 @@
#include "hal.h"
#include "ptime.h"
#define LOG_FLASH_ADDR1 0x080C0000 /* Log flash memory address 1 */
#define LOG_FLASH_ADDR2 0x080E0000 /* Log flash memory address 2 */
#define LOG_SECTOR_SIZE (128*1024) /* Log flash memory size */
typedef struct {
uint32_t id; // Serial ID
ptime_t time; // GPS time

Wyświetl plik

@ -5,6 +5,7 @@
#include "tracking.h"
#include "debug.h"
#include "padc.h"
#include "pac1720.h"
/**
* Sleeping method. Returns true if sleeping condition are given.
@ -16,20 +17,17 @@ bool p_sleep(const sleep_conf_t *config)
case SLEEP_WHEN_VBAT_BELOW_THRES:
return getBatteryVoltageMV() < config->vbat_thres;
case SLEEP_WHEN_VSOL_BELOW_THRES:
return getSolarVoltageMV() < config->vsol_thres;
case SLEEP_WHEN_ISOL_BELOW_THRES:
return pac1720_getIsol() < config->isol_thres;
case SLEEP_WHEN_VBAT_ABOVE_THRES:
return getBatteryVoltageMV() > config->vbat_thres;
case SLEEP_WHEN_VSOL_ABOVE_THRES:
return getSolarVoltageMV() > config->vsol_thres;
case SLEEP_WHEN_ISOL_ABOVE_THRES:
return pac1720_getIsol() > config->isol_thres;
case SLEEP_WHEN_DISCHARGING:
case SLEEP_WHEN_CHARGING:
case SLEEP_WHEN_INSIDE_ITU1:
case SLEEP_WHEN_INSIDE_ITU2:
case SLEEP_WHEN_INSIDE_ITU3:
TRACE_WARN("Sleeping method not implemented");
return false;

Wyświetl plik

@ -52,20 +52,17 @@ typedef struct {
typedef enum {
SLEEP_DISABLED,
SLEEP_WHEN_VBAT_BELOW_THRES,
SLEEP_WHEN_VSOL_BELOW_THRES,
SLEEP_WHEN_ISOL_BELOW_THRES,
SLEEP_WHEN_VBAT_ABOVE_THRES,
SLEEP_WHEN_VSOL_ABOVE_THRES,
SLEEP_WHEN_ISOL_ABOVE_THRES,
SLEEP_WHEN_DISCHARGING,
SLEEP_WHEN_CHARGING,
SLEEP_WHEN_INSIDE_ITU1,
SLEEP_WHEN_INSIDE_ITU2,
SLEEP_WHEN_INSIDE_ITU3
SLEEP_WHEN_CHARGING
} sleep_type_t;
typedef struct {
sleep_type_t type;
uint16_t vbat_thres;
uint16_t vsol_thres;
uint16_t isol_thres;
} sleep_conf_t;
typedef struct {