Skip to content

Commit

Permalink
added TCP interface for GPS
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensElflein committed Nov 10, 2024
1 parent 7fdc4c0 commit 4ffb40a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/drivers/gps/gps_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

namespace xbot::driver::gps {

void GpsDriver::RawDataInput(uint8_t *data, size_t size) {
if(!IsRawMode())
return;
send_raw(data, size);
}
GpsDriver::GpsDriver() {
datum_lat_ = datum_long_ = NAN;
}
Expand Down Expand Up @@ -74,8 +79,9 @@ void GpsDriver::SetDatum(double datum_lat, double datum_long, double datum_heigh
}

bool GpsDriver::send_raw(const void *data, size_t size) {
// sdWrite(uart, static_cast<const uint8_t*>(data), size);
chMtxLock(&mutex_);
uartSendFullTimeout(uart_, &size, data, TIME_INFINITE);
chMtxUnlock(&mutex_);
return true;
}

Expand Down Expand Up @@ -118,8 +124,12 @@ void GpsDriver::threadFunc() {
}
if (processing_buffer_len_ > 0) {
ProcessBytes(processing_buffer_, processing_buffer_len_);
last_ndtr = 0;
if(IsRawMode()) {
RawDataOutput(processing_buffer_, processing_buffer_len_);
}
}
last_ndtr = 0;
processing_buffer_len_ = 0;
processing_done_ = true;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/drivers/gps/gps_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

#include <etl/delegate.h>

#include <debug/debuggable_driver.hpp>

#include "ch.h"
#include "hal.h"

namespace xbot::driver::gps {
class GpsDriver {
class GpsDriver : public DebuggableDriver {
public:
void RawDataInput(uint8_t *data, size_t size) override;
explicit GpsDriver();

virtual ~GpsDriver() = default;
~GpsDriver() override = default;

/*
* The final GPS state we're interested in.
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/gps/ublox_gps_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#ifndef XBOT_DRIVER_GPS_UBLOX_GPS_DRIVER_H
#define XBOT_DRIVER_GPS_UBLOX_GPS_DRIVER_H

#include <debug/debuggable_driver.hpp>

#include "gps_driver.h"
#include "ubx_datatypes.h"



namespace xbot::driver::gps {
class UbxGpsDriver : public GpsDriver {
public:
Expand Down

0 comments on commit 4ffb40a

Please sign in to comment.