Small changes for PR

This commit is contained in:
Pavel Zakopaylo 2023-12-01 15:15:29 +11:00
parent c48950e07b
commit dddb316d91
No known key found for this signature in database
GPG Key ID: 9D4130BD5891F5CB
2 changed files with 19 additions and 3 deletions

View File

@ -20,6 +20,14 @@ static void blisp_dlog(const char* format, ...)
fputc('\n', stderr);
}
static void blisp_dlog_no_nl(const char* format, ...) {
fflush(stdout);
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
static void sleep_ms(int milliseconds) {
#ifdef WIN32
@ -95,4 +103,4 @@ static uint32_t crc32_calculate(const void *data, size_t data_len)
}
#endif
#endif

View File

@ -234,7 +234,7 @@ blisp_return_t blisp_device_handshake(struct blisp_device* device,
if (device->chip->type == BLISP_CHIP_BL808) {
sleep_ms(300);
const uint8_t second_handshake[] = { 0x50, 0x00, 0x08, 0x00, 0x38, 0xF0, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18 };
const static uint8_t second_handshake[] = { 0x50, 0x00, 0x08, 0x00, 0x38, 0xF0, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18 };
ret = sp_blocking_write(serial_port, second_handshake, sizeof(second_handshake), 300);
if (ret < 0) {
blisp_dlog("Second handshake write failed, ret %d", ret);
@ -250,8 +250,16 @@ blisp_return_t blisp_device_handshake(struct blisp_device* device,
}
}
}
if (!ok) {
blisp_dlog("Received no response from chip.");
blisp_dlog("Received incorrect handshake response from chip.");
blisp_dlog_no_nl("Could not find 0x%02X 0x%02X ('O', 'K') in: ", 'O', 'K');
if (ret) {
for (uint8_t j=0; j <= ret; j++) {
blisp_dlog_no_nl("0x%02X ", device->rx_buffer[j]);
}
}
blisp_dlog("");
return BLISP_ERR_NO_RESPONSE;
}