kopia lustrzana https://github.com/DL7AD/pecanpico10
Updates:
- Specify timeouts in sysinterval in ublox.c - Minor documentation updatesDevelopment
rodzic
8781b3026f
commit
a000c087b1
|
@ -15,8 +15,8 @@ const conf_t conf_flash_default = {
|
|||
.pos_pri = {
|
||||
.beacon = {
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60 * 2),
|
||||
.init_delay = TIME_S2I(0),
|
||||
.cycle = TIME_S2I(60 * 10),
|
||||
.init_delay = TIME_S2I(5),
|
||||
.fixed = true, // Add lat, lon alt fields when enabling fixed
|
||||
.lat = -337331175, // Degrees (expressed in 1e-7 form)
|
||||
.lon = 1511143478, // Degrees (expressed in 1e-7 form)
|
||||
|
@ -39,18 +39,18 @@ const conf_t conf_flash_default = {
|
|||
.pos_sec = {
|
||||
.beacon = {
|
||||
.active = true,
|
||||
.cycle = TIME_S2I(60 * 5), // Beacon interval
|
||||
.cycle = TIME_S2I(10), // Beacon interval
|
||||
.init_delay = TIME_S2I(10),
|
||||
.fixed = false
|
||||
},
|
||||
.radio_conf = {
|
||||
.pwr = 0x1F,
|
||||
.freq = 144800000,
|
||||
.mod = MOD_2FSK_9k6,
|
||||
.freq = 144850000,
|
||||
.mod = MOD_AFSK,
|
||||
.cca = 0x4F
|
||||
},
|
||||
// App identity
|
||||
.call = "VK2GJ-2",
|
||||
.call = "VK2GJ-11",
|
||||
.path = "WIDE2-1",
|
||||
.symbol = SYM_ANTENNA,
|
||||
.aprs_msg = false, // Enable APRS message reception on this app
|
||||
|
@ -79,13 +79,13 @@ const conf_t conf_flash_default = {
|
|||
.res = RES_QVGA,
|
||||
.quality = 4,
|
||||
.buf_size = 15 * 1024,
|
||||
.redundantTx = false
|
||||
.redundantTx = true
|
||||
},
|
||||
|
||||
// Secondary image app
|
||||
.img_sec = {
|
||||
.svc_conf = {
|
||||
.active = true,
|
||||
.active = false,
|
||||
.cycle = TIME_S2I(60 * 2),
|
||||
.init_delay = TIME_S2I(10),
|
||||
.send_spacing = TIME_S2I(5)
|
||||
|
@ -159,13 +159,13 @@ const conf_t conf_flash_default = {
|
|||
.tx = {
|
||||
// Transmit radio configuration
|
||||
.radio_conf = {
|
||||
.freq = FREQ_RX_APRS,
|
||||
.freq = 144850000,
|
||||
.pwr = 0x7F,
|
||||
.mod = MOD_AFSK,
|
||||
.cca = 0x5F
|
||||
},
|
||||
// Digipeat transmission identity
|
||||
.call = "VK2GJ-5",
|
||||
.call = "VK2GJ-11",
|
||||
.path = "WIDE2-1",
|
||||
.symbol = SYM_DIGIPEATER,
|
||||
// A digipeater beacon can be added using one of the POS apps
|
||||
|
@ -189,7 +189,7 @@ const conf_t conf_flash_default = {
|
|||
|
||||
// APRS
|
||||
// How often to send telemetry config (global for beacons)
|
||||
.tel_enc_cycle = TIME_S2I(3600),
|
||||
.tel_enc_cycle = TIME_S2I(60 * 60),
|
||||
|
||||
// The default APRS frequency when geofence is not resolved
|
||||
.freq = FREQ_APRS_AUSTRALIA,
|
||||
|
|
|
@ -315,7 +315,7 @@ THD_FUNCTION(pktConsole, arg) {
|
|||
shellInit();
|
||||
shelltp = chThdCreateFromHeap(NULL,
|
||||
THD_WORKING_AREA_SIZE(3 * 1024),
|
||||
"shell", NORMALPRIO + 1,
|
||||
"shell", LOWPRIO,
|
||||
shellThread,
|
||||
(void *)&shell_cfg);
|
||||
if(shelltp == NULL) {
|
||||
|
@ -392,7 +392,7 @@ msg_t pktStartConsole(BaseAsynchronousChannel *ser) {
|
|||
thread_t *con_thd = chThdCreateFromHeap(NULL,
|
||||
THD_WORKING_AREA_SIZE(1 * 1024),
|
||||
"CON",
|
||||
LOWPRIO + 10,
|
||||
LOWPRIO,
|
||||
pktConsole,
|
||||
ser);
|
||||
if(con_thd == NULL)
|
||||
|
|
|
@ -1220,11 +1220,10 @@ pdcmi_error_t OV5640_Capture(uint8_t* buffer, uint32_t size,
|
|||
}
|
||||
|
||||
case PDCMI_DMA_END_BUFFER: {
|
||||
TRACE_ERROR("CAM > DMA ran out of buffer space in DBM"
|
||||
" (image possibly useable).");
|
||||
*size_sampled = dma_control.transfer_count;
|
||||
TRACE_ERROR("CAM > DMA ran out of buffer space in DBM at 0x%x of 0x%x",
|
||||
dma_control.transfer_count, size);
|
||||
*size_sampled = 0;
|
||||
return PDCMI_DMA_DBM_OVERFLOW_ERR;
|
||||
|
||||
}
|
||||
|
||||
case PDCMI_CAPTURE_TIMEOUT: {
|
||||
|
|
|
@ -1483,7 +1483,9 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
|
||||
chDbgAssert(pp != NULL, "no packet in radio task");
|
||||
|
||||
/* Request radio lock. */
|
||||
msg_t msg = pktLockRadio(radio, RADIO_TX, TIME_INFINITE);
|
||||
|
||||
if(msg == MSG_RESET || msg == MSG_TIMEOUT) {
|
||||
TRACE_ERROR("SI > AFSK TX reset or timeout from radio acquisition");
|
||||
|
||||
|
@ -1512,12 +1514,9 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
Si446x_terminateReceive(radio);
|
||||
|
||||
/*
|
||||
* Set receive for CCA detection to AFSK.
|
||||
* TODO: Implement a standard carrier detect setup.
|
||||
* Set the radio for AFSK upsampled mode.
|
||||
* Set receive for CCA detection.
|
||||
*/
|
||||
//Si446x_setModemCCAdetection(radio);
|
||||
|
||||
/* Set the radio for AFSK upsampled mode. */
|
||||
Si446x_setModemAFSK_TX(radio);
|
||||
|
||||
/* Initialize variables for AFSK encoder. */
|
||||
|
@ -1637,13 +1636,16 @@ THD_FUNCTION(bloc_si_fifo_feeder_afsk, arg) {
|
|||
* If no timeout event go back and load more data to FIFO.
|
||||
* TODO: Use interrupt to trigger FIFO fill.
|
||||
*/
|
||||
eventmask_t evt = chEvtWaitAnyTimeout(SI446X_EVT_TX_TIMEOUT,
|
||||
chTimeUS2I(833 * 8));
|
||||
/* eventmask_t evt = chEvtWaitAnyTimeout(SI446X_EVT_TX_TIMEOUT,
|
||||
chTimeUS2I(833 * 8));*/
|
||||
eventmask_t evt = chEvtGetAndClearEvents(SI446X_EVT_TX_TIMEOUT);
|
||||
if(evt) {
|
||||
exit_msg = MSG_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Let other threads run. */
|
||||
chThdYield();
|
||||
} /* End while(). */
|
||||
} else {
|
||||
/* Transmit start failed. */
|
||||
TRACE_ERROR("SI > Transmit start failed");
|
||||
|
@ -1779,12 +1781,9 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
Si446x_terminateReceive(radio);
|
||||
|
||||
/*
|
||||
* Set receive for CCA detection to AFSK.
|
||||
* TODO: Implement a standard carrier detect setup.
|
||||
* Set the radio for 2FSK transmission.
|
||||
* Set receive for CCA detection.
|
||||
*/
|
||||
//Si446x_setModemCCAdetection(radio);
|
||||
|
||||
/* Set parameters for 2FSK transmission. */
|
||||
Si446x_setModem2FSK_TX(radio, rto->tx_speed);
|
||||
|
||||
/* Initialize variables for 2FSK encoder. */
|
||||
|
@ -1800,7 +1799,8 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
|
||||
/*
|
||||
* Use the specified CCA RSSI level.
|
||||
* CCA will be set to blind send after first packet.
|
||||
* This can be be blind send (PKT_SI446X_NO_CCA_RSSI).
|
||||
* In burst mode CCA will be set to blind send after first packet.
|
||||
*/
|
||||
radio_squelch_t rssi = rto->squelch;
|
||||
|
||||
|
@ -1903,13 +1903,16 @@ THD_FUNCTION(bloc_si_fifo_feeder_fsk, arg) {
|
|||
* If no timeout event go back and load more data to FIFO.
|
||||
* TODO: Use interrupt to trigger FIFO fill.
|
||||
*/
|
||||
eventmask_t evt = chEvtWaitAnyTimeout(SI446X_EVT_TX_TIMEOUT,
|
||||
chTimeUS2I(104 * 8 * 10));
|
||||
/* eventmask_t evt = chEvtWaitAnyTimeout(SI446X_EVT_TX_TIMEOUT,
|
||||
chTimeUS2I(104 * 8 * 10));*/
|
||||
eventmask_t evt = chEvtGetAndClearEvents(SI446X_EVT_TX_TIMEOUT);
|
||||
if(evt) {
|
||||
exit_msg = MSG_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Let other threads run. */
|
||||
chThdYield();
|
||||
} /* End while(). */
|
||||
} else {
|
||||
/* Transmit start failed. */
|
||||
TRACE_ERROR("SI > 2FSK transmit start failed");
|
||||
|
|
|
@ -132,15 +132,16 @@ uint8_t gps_receive_ack(uint8_t class_id, uint8_t msg_id, uint16_t timeout) {
|
|||
*/
|
||||
uint16_t gps_receive_payload(uint8_t class_id, uint8_t msg_id,
|
||||
unsigned char *payload, size_t size,
|
||||
uint16_t timeout) {
|
||||
sysinterval_t timeout) {
|
||||
uint8_t rx_byte;
|
||||
enum {UBX_A, UBX_B, CLASSID, MSGID, LEN_A, LEN_B, PAYLOAD} state = UBX_A;
|
||||
uint16_t payload_cnt = 0;
|
||||
uint16_t payload_len = 0;
|
||||
|
||||
systime_t sNow = chVTGetSystemTime();
|
||||
systime_t sEnd = chTimeAddX(sNow, timeout);
|
||||
|
||||
while(chVTIsSystemTimeWithin(sNow, chTimeAddX(sNow, TIME_MS2I(timeout)))) {
|
||||
while(chVTIsSystemTimeWithin(sNow, sEnd)) {
|
||||
|
||||
// Receive one byte
|
||||
if(!gps_receive_byte(&rx_byte)) {
|
||||
|
@ -152,7 +153,6 @@ uint16_t gps_receive_payload(uint8_t class_id, uint8_t msg_id,
|
|||
switch (state) {
|
||||
case UBX_A:
|
||||
if(rx_byte == 0xB5) state = UBX_B;
|
||||
//else state = UBX_A;
|
||||
break;
|
||||
case UBX_B:
|
||||
if(rx_byte == 0x62) state = CLASSID;
|
||||
|
@ -176,7 +176,6 @@ uint16_t gps_receive_payload(uint8_t class_id, uint8_t msg_id,
|
|||
break;
|
||||
case PAYLOAD:
|
||||
payload[payload_cnt++] = rx_byte;
|
||||
//payload_cnt++;
|
||||
if(payload_cnt == payload_len)
|
||||
return payload_len;
|
||||
if(payload_cnt > size)
|
||||
|
@ -202,7 +201,8 @@ bool gps_get_sv_info(gps_svinfo_t *svinfo, size_t size) {
|
|||
uint8_t navsvinfo_req[] = {0xB5, 0x62, 0x01, 0x30, 0x00, 0x00, 0x00, 0x00};
|
||||
gps_transmit_string(navsvinfo_req, sizeof(navsvinfo_req));
|
||||
|
||||
if(!gps_receive_payload(0x01, 0x30, (unsigned char*)svinfo, size, 3000)) { // Receive request
|
||||
if(!gps_receive_payload(0x01, 0x30, (unsigned char*)svinfo, size,
|
||||
TIME_MS2I(3000))) { // Receive request
|
||||
TRACE_ERROR("GPS > NAV-SVINFO Polling FAILED");
|
||||
return false;
|
||||
}
|
||||
|
@ -225,7 +225,8 @@ bool gps_get_fix(gpsFix_t *fix) {
|
|||
uint8_t navpvt_req[] = {0xB5, 0x62, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00};
|
||||
gps_transmit_string(navpvt_req, sizeof(navpvt_req));
|
||||
|
||||
if(!gps_receive_payload(0x01, 0x07, navpvt, sizeof(navpvt), 3000)) { // Receive request
|
||||
if(!gps_receive_payload(0x01, 0x07, navpvt, sizeof(navpvt),
|
||||
TIME_MS2I(3000))) { // Receive request
|
||||
TRACE_ERROR("GPS > NAV-PVT Polling FAILED");
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +234,8 @@ bool gps_get_fix(gpsFix_t *fix) {
|
|||
uint8_t navstatus_req[] = {0xB5, 0x62, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00};
|
||||
gps_transmit_string(navstatus_req, sizeof(navstatus_req));
|
||||
|
||||
if(!gps_receive_payload(0x01, 0x03, navstatus, sizeof(navstatus), 3000)) { // Receive request
|
||||
if(!gps_receive_payload(0x01, 0x03, navstatus, sizeof(navstatus),
|
||||
TIME_MS2I(3000))) { // Receive request
|
||||
TRACE_ERROR("GPS > NAV-STATUS Polling FAILED");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -363,13 +363,8 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
"resume after transmit", radio);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* TODO: Rationalise/rework the stream enable.
|
||||
* Resume packet stream. */
|
||||
/* Resume receive packet stream. */
|
||||
pktEnableRadioStream(radio);
|
||||
//pktLLDradioAttachStream(radio);
|
||||
//pktEnableRadioPWM(radio);
|
||||
//pktLLDradioResumeDecoding(radio);
|
||||
} else {
|
||||
/* Enter standby state (low power). */
|
||||
TRACE_INFO("RAD > Radio %d entering standby", radio);
|
||||
|
@ -390,8 +385,6 @@ THD_FUNCTION(pktRadioManager, arg) {
|
|||
/* Return radio task object to free list. */
|
||||
chFifoReturnObject(radio_queue, (radio_task_object_t *)task_object);
|
||||
} /* End while. */
|
||||
/* chFactoryReleaseObjectsFIFO(handler->the_radio_fifo);
|
||||
chThdExit(MSG_OK);*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -720,6 +713,7 @@ msg_t pktLockRadio(const radio_unit_t radio, const radio_mode_t mode,
|
|||
#else
|
||||
if((msg = chBSemWaitTimeout(&handler->radio_sem, timeout)) == MSG_OK) {
|
||||
if((msg = OV5640_LockPDCMI()) != MSG_OK)
|
||||
/* If PDCMI lock failed the release the radio lock. */
|
||||
chBSemSignal(&handler->radio_sem);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -139,12 +139,12 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
|
|||
uint16_t batt = stm32_get_vbat();
|
||||
if(batt < conf_sram.gps_on_vbat) {
|
||||
getPositionFallback(tp, ltp, GPS_LOWBATT1);
|
||||
/* In case GPS was already on power it off. */
|
||||
/* In case GPS was already on then power it off. */
|
||||
GPS_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Try to switch on GPS. */
|
||||
/* Try to switch on GPS. If there is an error switch off. */
|
||||
if(!GPS_Init()) {
|
||||
getPositionFallback(tp, ltp, GPS_ERROR);
|
||||
GPS_Deinit();
|
||||
|
@ -185,13 +185,29 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
|
|||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(!isGPSLocked(&gpsFix)) {
|
||||
ptime_t time;
|
||||
getTime(&time);
|
||||
/*
|
||||
* GPS was switched on but it failed to get a lock within timeout period.
|
||||
* Keep GPS switched on.
|
||||
* Keep GPS switched on if...
|
||||
* - battery threshold met and not a run once request.
|
||||
* - battery threshold is met and location is fixed but RTC not set.
|
||||
* - and there are no other users wanting to keep power on.
|
||||
*/
|
||||
TRACE_WARN("COLL > GPS sampling finished GPS LOSS");
|
||||
getPositionFallback(tp, ltp, GPS_LOSS);
|
||||
if(conf_sram.gps_onper_vbat != 0
|
||||
&& batt >= conf_sram.gps_onper_vbat
|
||||
&& !config->run_once
|
||||
&& !(config->beacon.fixed && time.year != RTC_BASE_YEAR)) {
|
||||
TRACE_INFO("COLL > Keep GPS switched on because VBAT >= %dmV",
|
||||
conf_sram.gps_onper_vbat);
|
||||
} else {
|
||||
GPS_Deinit();
|
||||
TRACE_INFO("COLL > Switching off GPS");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -204,6 +220,7 @@ static bool aquirePosition(dataPoint_t* tp, dataPoint_t* ltp,
|
|||
gps_get_model_name(gpsFix.model));
|
||||
/* Enable power saving mode. */
|
||||
gps_switch_power_save_mode(true);
|
||||
|
||||
gps_svinfo_t svinfo;
|
||||
if(gps_get_sv_info(&svinfo, sizeof(svinfo))) {
|
||||
TRACE_INFO("GPS > Space Vehicle info iTOW=%d numCh=%02d globalFlags=%d",
|
||||
|
|
|
@ -912,6 +912,7 @@ static bool resend_image_packet(const uint8_t *image,
|
|||
chSemSignal(&tx_complete);
|
||||
return false;
|
||||
}
|
||||
/* Transmit complete releases the semaphore. */
|
||||
return true;
|
||||
} /* End case SSDV_BUFFER_FULL/SSDV_EOI. */
|
||||
|
||||
|
@ -1152,13 +1153,15 @@ static msg_t analyze_image(const uint8_t *image, size_t image_len) {
|
|||
|
||||
ssdv_t ssdv;
|
||||
uint8_t pkt[SSDV_PKT_SIZE];
|
||||
//size_t b = 1;
|
||||
uint8_t c;
|
||||
|
||||
ssdv_enc_init(&ssdv, SSDV_TYPE_NOFEC, "", 0, 7);
|
||||
ssdv_enc_set_buffer(&ssdv, pkt);
|
||||
ssdv_enc_feed(&ssdv, image, image_len);
|
||||
|
||||
systime_t sNow = chVTGetSystemTime();
|
||||
systime_t sEnd = chTimeAddX(sNow, TIME_MS2I(4000));
|
||||
|
||||
do {
|
||||
|
||||
switch(c = ssdv_enc_get_packet(&ssdv)) {
|
||||
|
@ -1166,28 +1169,32 @@ static msg_t analyze_image(const uint8_t *image, size_t image_len) {
|
|||
TRACE_ERROR("CAM > Error in image (premature end of file at %d)",
|
||||
image_len);
|
||||
return MSG_TIMEOUT;
|
||||
}
|
||||
} /* End case. */
|
||||
|
||||
case SSDV_BUFFER_FULL: {
|
||||
chThdSleep(TIME_MS2I(5));
|
||||
//chThdSleep(TIME_MS2I(5));
|
||||
chThdYield();
|
||||
break;
|
||||
}
|
||||
} /* End case. */
|
||||
|
||||
case SSDV_EOI: {
|
||||
return MSG_OK;
|
||||
}
|
||||
} /* End case. */
|
||||
|
||||
case SSDV_OK: {
|
||||
continue;
|
||||
}
|
||||
} /* End case. */
|
||||
|
||||
default: {
|
||||
/* This catches SSDV_ERROR. */
|
||||
TRACE_ERROR("CAM > Error in image (ssdv_enc_get_packet failed:"
|
||||
" %d at %d of %d)", c, (image_len - ssdv.in_len), image_len);
|
||||
return MSG_TIMEOUT;
|
||||
}
|
||||
} /* End case. */
|
||||
} /* End switch. */
|
||||
} while(true);/* End while. */
|
||||
} while(chVTIsSystemTimeWithin(sNow, sEnd));/* End while. */
|
||||
TRACE_ERROR("CAM > Timeout analyzing image");
|
||||
return MSG_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Ładowanie…
Reference in New Issue