Skip to content

Commit

Permalink
bug: adds fixes to xbee radio config and coms
Browse files Browse the repository at this point in the history
  • Loading branch information
acarrou committed Oct 24, 2023
1 parent a72b18d commit 8379aa6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
19 changes: 11 additions & 8 deletions demos/applications/telemetry-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ hal::status application(hardware_map& p_map)
auto spi2 = HAL_CHECK(hal::lpc40::spi::get(2));
auto chip_select = HAL_CHECK(hal::lpc40::output_pin::get(1, 8));

hal::print(console, "\n\nTelemetry Recorder Starting...\n\n");
hal::print(console, "\n\nTelemetry Recorder Starting. May take a few seconds...\n\n");

// Device initialization
auto micro_sd =
Expand Down Expand Up @@ -130,26 +130,29 @@ hal::status application(hardware_map& p_map)
telemetry_recorder_data.gps_time);



hal::print<512>(console, telem_data);
float heading = computeHeading(telemetry_recorder_data.mag_x, telemetry_recorder_data.mag_y, 0.0);
hal::print<128>(console, "\n\nHeading: %f°", heading);

hal::print(console, "\n\n============================================\n\n");

hal::print(console, "Transmitting Data to Ground Station...\n\n");
telemetry_recorder.transmit("Here is some data!\n");
telemetry_recorder.transmit(telem_data);

hal::print(console, "Storing Data to SD Card...\n\n");
telemetry_recorder.store(telem_data);
std::string_view message = "\nHello here is some data\n";

telemetry_recorder.transmit(message);
telemetry_recorder.transmit(telem_data);

hal::print(console, "Recieveing Data from Ground Station...\n\n");
auto recieved_data = HAL_CHECK(telemetry_recorder.recieve());
auto recieved_data1 = HAL_CHECK(telemetry_recorder.recieve());
hal::print(console,
"\n=================== RECIEVED DATA ===================\n");
hal::print(console, recieved_data);
hal::print(console, recieved_data1);
hal::print(console,
"======================================================\n\n");
"\n======================================================\n\n");

// hal::delay(clock, 500ms); // enable to see status of XBEE radio

}

Expand Down
11 changes: 5 additions & 6 deletions demos/platforms/lpc4078.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ hal::result<hardware_map> initialize_platform()
.baud_rate = 115200,
}));

static auto uart1 = HAL_CHECK(hal::lpc40::uart::get(1,
uart1_buffer,
hal::serial::settings{
.baud_rate = 115200,
}));

static auto i2c = HAL_CHECK((hal::lpc40::i2c::get(2,
hal::i2c::settings{
.clock_rate = 100.0_kHz,
Expand All @@ -68,6 +62,11 @@ hal::result<hardware_map> initialize_platform()
.baud_rate = 38400,
}));

static auto uart1 = HAL_CHECK(hal::lpc40::uart::get(1,
uart1_buffer,
hal::serial::settings{
.baud_rate = 9600,
}));


return hardware_map{
Expand Down
1 change: 1 addition & 0 deletions include/telemetry-recorder/telemetry-recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class telemetry_recorder
hal::result<float> gps_baro_altitude_offset();
hal::result<std::span<hal::byte>> recieve();
hal::status transmit(std::string_view message);
hal::status transmit(const char* formatted_data);
hal::status store(std::string_view message);

private:
Expand Down
12 changes: 8 additions & 4 deletions src/telemetry-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ hal::result<std::span<hal::byte>> telemetry_recorder::recieve()
return data;
}

hal::status telemetry_recorder::transmit(std::string_view message)
{
m_xbee->write(hal::as_bytes(message));
return hal::success();
hal::status telemetry_recorder::transmit(std::string_view message) {
auto byte_data = hal::as_bytes(message);
m_xbee->write(byte_data);
return hal::success();
}

hal::status telemetry_recorder::transmit(const char* formatted_data) {
return this->transmit(std::string_view(formatted_data));
}

hal::status telemetry_recorder::store(std::string_view message)
Expand Down

0 comments on commit 8379aa6

Please sign in to comment.