Browse Source

fix issues with error interpretation

try-fix-comms-errors
Alex Mikhalev 6 years ago
parent
commit
a36caa53f1
  1. 27
      main/e32_driver.cc
  2. 8
      main/e32_driver.hh
  3. 3
      main/ugv_comms.cc

27
main/e32_driver.cc

@ -251,38 +251,31 @@ esp_err_t E32_Driver::WriteParams(const Params& params) { @@ -251,38 +251,31 @@ esp_err_t E32_Driver::WriteParams(const Params& params) {
return ESP_OK;
}
esp_err_t E32_Driver::Write(Address address, Channel channel,
int E32_Driver::Write(Address address, Channel channel,
const uint8_t* data, size_t data_size) {
esp_err_t ret;
int written;
if (params_.tx_mode == TxFixed) {
uint8_t header[3];
header[0] = address >> 8;
header[1] = address & 0xFF;
header[2] = channel;
ret = uart_write_bytes(config_.uart_port, (char*)header, sizeof(header));
if (ret != ESP_OK) {
goto error;
written = uart_write_bytes(config_.uart_port, (char*)header, sizeof(header));
if (written < 0) {
return written;
}
}
ret = uart_write_bytes(config_.uart_port, (char*)data, data_size);
if (ret != ESP_OK) {
goto error;
}
return ESP_OK;
error:
ESP_LOGE(TAG, "Write error %d", ret);
return ret;
written = uart_write_bytes(config_.uart_port, (char*)data, data_size);
return written;
}
esp_err_t E32_Driver::Write(const uint8_t* data, size_t data_size) {
int E32_Driver::Write(const uint8_t* data, size_t data_size) {
return Write(params_.address, params_.comm_channel, data, data_size);
}
esp_err_t E32_Driver::Write(Address address, Channel channel,
int E32_Driver::Write(Address address, Channel channel,
const std::string& data) {
return Write(address, channel, (uint8_t*)data.c_str(), data.size());
}
esp_err_t E32_Driver::Write(const std::string& data) {
int E32_Driver::Write(const std::string& data) {
return Write((uint8_t*)data.c_str(), data.size());
}

8
main/e32_driver.hh

@ -61,11 +61,11 @@ class E32_Driver { @@ -61,11 +61,11 @@ class E32_Driver {
esp_err_t ReadParams(Params& params);
esp_err_t WriteParams(const Params& params);
esp_err_t Write(Address address, Channel channel, const uint8_t* data,
int Write(Address address, Channel channel, const uint8_t* data,
size_t data_size);
esp_err_t Write(const uint8_t* data, size_t data_size);
esp_err_t Write(Address address, Channel channel, const std::string& data);
esp_err_t Write(const std::string& data);
int Write(const uint8_t* data, size_t data_size);
int Write(Address address, Channel channel, const std::string& data);
int Write(const std::string& data);
int Read(uint8_t* data, int max_len,
TickType_t ticks_to_wait = portMAX_DELAY);

3
main/ugv_comms.cc

@ -260,7 +260,8 @@ esp_err_t CommsClass::SendPacket(const char *data, size_t size) { @@ -260,7 +260,8 @@ esp_err_t CommsClass::SendPacket(const char *data, size_t size) {
}
uint8_t sz = size;
lora.Write(&sz, sizeof(sz));
return lora.Write((uint8_t *)data, size);
lora.Write((uint8_t *)data, size);
return ESP_OK;
#endif
}

Loading…
Cancel
Save