Skip to content

Commit

Permalink
5 hz
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Oct 21, 2024
1 parent 0aff120 commit 5c4be73
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
8 changes: 7 additions & 1 deletion sfy-buoy/sfy-ext-gps/ext-gps-mod/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
uint8_t hour = ubxDataStruct->hour;
uint8_t minute = ubxDataStruct->min;
uint8_t sec = ubxDataStruct->sec;
int32_t nano = ubxDataStruct->nano;
uint32_t nano = ubxDataStruct->nano;

String datetime = String(year) + "-" + String(month) + "-" + String(day) + ":" + String(hour) + ":" + String(minute) + ":" + String(sec) + "." + String(nano);
Serial.print(F("Time: "));
Expand Down Expand Up @@ -293,9 +293,15 @@ void setup_gps() {
// When the module is _locked_ to GNSS time, make it generate a second pulse every 30 seconds
// myGNSS.addCfgValset(UBLOX_CFG_TP_PERIOD_LOCK_TP1, 50000); // Set the period to 30,000,000 us
// myGNSS.addCfgValset(UBLOX_CFG_TP_LEN_LOCK_TP1, 10000); // Set the pulse length to 1,000,000 us

// 1 Hz
myGNSS.addCfgValset(UBLOX_CFG_TP_PERIOD_LOCK_TP1, 1000000); // Set the period to 30,000,000 us
myGNSS.addCfgValset(UBLOX_CFG_TP_LEN_LOCK_TP1, 100000); // Set the pulse length to 1,000,000 us

// 5 Hz
myGNSS.addCfgValset(UBLOX_CFG_TP_PERIOD_LOCK_TP1, (1000000/5)); // Set the period to 30,000,000 us
myGNSS.addCfgValset(UBLOX_CFG_TP_LEN_LOCK_TP1, (100000/5)); // Set the pulse length to 1,000,000 us

// Now set the time pulse parameters
if (myGNSS.sendCfgValset() == false)
{
Expand Down
8 changes: 4 additions & 4 deletions sfy-buoy/sfy-ext-gps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ fn main() -> ! {

// XXX: This needs to be adapted to frequency, and queue length. Maybe just remove when we
// have the remaining space check? Check after Hjeltefjorden deployment.
const LOOP_DELAY: u32 = 1_00;
const SHORT_LOOP_DELAY: u32 = 1_00;
const LOOP_DELAY: u32 = 3_000;
const SHORT_LOOP_DELAY: u32 = 3_000;

// Process data and communication for the Notecard.
if ((now - last) > LOOP_DELAY as i64)
Expand All @@ -386,15 +386,15 @@ fn main() -> ! {
let l = location.check_retrieve(&STATE, &mut delay, &mut note);

#[cfg(feature = "storage")]
defmt::debug!(
defmt::warn!(
"notecard iteration, now: {}, note queue: {}, storage queue: {}",
now,
imu_queue.len(),
storage_manager.storage_queue.len()
);

#[cfg(not(feature = "storage"))]
defmt::debug!(
defmt::warn!(
"notecard iteration, now: {}, note queue: {}, gps queue: {}",
now,
imu_queue.len(),
Expand Down
13 changes: 11 additions & 2 deletions sfy-buoy/src/gps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,22 @@ where
defmt::debug!("Reading GPS package from serial.. sample buf: {}", self.buf.len());
let mut state = ParseState::StartBracket;

let mut timeout = 0_u32;

while !matches!(state, ParseState::EndBracket) {
if self.buf.len() == self.buf.capacity() {
defmt::error!("gps telegram buffer is full.");
break;
}

if timeout > 1_000_000 {
defmt::error!("gps: uart timed out.");
break;
}

match self.gps.read() {
Ok(w) => {
timeout = 0;
match state {
ParseState::StartBracket => {
if w == b'{' {
Expand All @@ -252,9 +260,10 @@ where
}
}

Err(nb::Error::WouldBlock) => { /* wait */ } // TODO: timeout!
Err(nb::Error::WouldBlock) => { timeout += 1; } // TODO: timeout!
Err(nb::Error::Other(_)) => {
defmt::error!("ext-gps: error reading from uart");
timeout += 1;
}
}
}
Expand All @@ -280,7 +289,7 @@ where
// let current = sample.time + (now - pps_time);
// drift = current - now
}
Err(_) => error!("Failed to parse GPS telegram: {}", &buf),
Err(_) => error!("Failed to parse GPS telegram."),
}

// TODO: Not really handling extra data.
Expand Down

0 comments on commit 5c4be73

Please sign in to comment.