Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved a startup issue with serial setup that could prevent the device from hashing #463

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/asic/bm1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void _send_BM1370(uint8_t header, uint8_t * data, uint8_t data_len, bool
}

// send serial data
if (SERIAL_send(buf, total_length, debug) == 0) {
if (SERIAL_send(buf, total_length, debug) == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to send data to BM1370");
}

Expand Down
2 changes: 1 addition & 1 deletion components/asic/include/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define SERIAL_BUF_SIZE 16
#define CHUNK_SIZE 1024

int SERIAL_send(uint8_t *, int, bool);
esp_err_t SERIAL_send(uint8_t *, int, bool);
void SERIAL_init(void);
void SERIAL_debug_rx(void);
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
Expand Down
10 changes: 8 additions & 2 deletions components/asic/serial.c
eandersson marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,22 @@ void SERIAL_set_baud(int baud)
uart_set_baudrate(UART_NUM_1, baud);
}

int SERIAL_send(uint8_t *data, int len, bool debug)
esp_err_t SERIAL_send(uint8_t *data, int len, bool debug)
{
int written = uart_write_bytes(UART_NUM_1, (const char *)data, len);

if (debug)
{
printf("tx: ");
prettyHex((unsigned char *)data, len);
printf("\n");
}

return uart_write_bytes(UART_NUM_1, (const char *)data, len);
if (written == 0) {
return ESP_FAIL;
}

return uart_wait_tx_done(UART_NUM_1, 1000 / portTICK_PERIOD_MS);
}

/// @brief waits for a serial response from the device
Expand Down