Skip to content

Commit

Permalink
serial sync for 1397 too.
Browse files Browse the repository at this point in the history
  • Loading branch information
skot committed Feb 15, 2024
1 parent 69b8a04 commit f45dd77
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions components/bm1397/bm1397.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,28 +379,29 @@ void BM1397_send_work(void *pvParameters, bm_job *next_bm_job)
asic_result *BM1397_receive_work(void)
{

// wait for a response, wait time is pretty arbitrary
int received = SERIAL_rx(asic_response_buffer, 9, 60000);

if (received < 0)
{
ESP_LOGI(TAG, "Error in serial RX");
return NULL;
}
else if (received == 0)
{
// Didn't find a solution, restart and try again
return NULL;
}

if (received != 9 || asic_response_buffer[0] != 0xAA || asic_response_buffer[1] != 0x55)
{
ESP_LOGI(TAG, "Serial RX invalid %i", received);
ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
return NULL;
}

return (asic_result *)asic_response_buffer;
// // wait for a response, wait time is pretty arbitrary
// int received = SERIAL_rx(asic_response_buffer, 9, 60000);

// if (received < 0)
// {
// ESP_LOGI(TAG, "Error in serial RX");
// return NULL;
// }
// else if (received == 0)
// {
// // Didn't find a solution, restart and try again
// return NULL;
// }

// if (received != 9 || asic_response_buffer[0] != 0xAA || asic_response_buffer[1] != 0x55)
// {
// ESP_LOGI(TAG, "Serial RX invalid %i", received);
// ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
// return NULL;
// }

// return (asic_result *)asic_response_buffer;
return SERIAL_rx_aa55(asic_response_buffer, 9);
}

task_result *BM1397_proccess_work(void *pvParameters)
Expand Down

0 comments on commit f45dd77

Please sign in to comment.