Open
Description
Is it correct to send data to Radex ONE this way and try to parse measure?
Form and send a new packet:
struct Keys {
int key_a;
int key_b;
int key_c;
int key_d;
} keys;
void ProcessKeys(uint8_t* input_array) {
keys.key_a += 0x04;
keys.key_c -= 0x04;
if (keys.key_a > 0xff) {
keys.key_a -= 0xfe;
keys.key_b += 0x01;
if (keys.key_b > 0xff) {
keys.key_b = 0x00;
}
keys.key_c -= 0x01;
}
else if (keys.key_c < 0x00) {
keys.key_c += 0xff;
keys.key_d -= 0x01;
if (keys.key_d < 0x00) {
keys.key_d = 0xff;
}
}
uint8_t data[18] = {0x7b, 0xff, 0x20, 0, 0x06, 0, (uint8_t)(keys.key_a),
(uint8_t)(keys.key_b), 0, 0, (uint8_t)(keys.key_c),
(uint8_t)(keys.key_d), 0, 0x08, 0x0c, 0, 0xf3, 0xf7};
for (int i = 0; i < 18; ++i) {
input_array[i] = data[i];
}
}
Parsing in callback function by the end of the transfer function:
void usb_transfer_complete(usb_transfer_t *transfer) {
printf("Transfer status %d, actual number of bytes transferred %d\n", transfer->status, transfer->actual_num_bytes);
ESP_LOGI(TAG, "Enter transfer callback");
if (transfer->status == USB_TRANSFER_STATUS_COMPLETED) {
ESP_LOGI(TAG, "USB transfer completed successfully!");
uint8_t* data = transfer->data_buffer;
ESP_LOGI(TAG, "Response: %f", ((float)(data[20]) + (float)(data[21]) * 256
+ (float)(data[22]) * 256 * 256) / 100.0);
}
else {
ESP_LOGI(TAG, "USB transfer failed with error code %d", transfer->status);
}
}
Result:
- All this done according to 'init.py' file, but I get weird values in response, for instance, '107861.3' and '146730.2'. What do I do wrong?
- Where did you find info about data format? Did you reverse-engineer that?
Metadata
Metadata
Assignees
Labels
No labels