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