I am not decode it, i try to read original encode data first.MicroController wrote: ↑Thu Nov 28, 2024 12:06 pm1) You're receiving 10x22 'bits', but decoding it to 20 bytes. Make sure you ignore/remove the stuffing bits.dzungpv wrote: ↑Thu Nov 28, 2024 11:40 am```
00155557 00155ff7 001d5f5f 00155557 00155557 0015f557 001dd57f 001557ff 00155557 0015575f 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
```
But receive only this raw data:
```
55 aa 55 80 57 e8 55 aa 55 aa f5 aa 77 fa 55 ff 55 aa 55 eb
```
I don't know why. the TX work fine.
2) Make sure you also remove the parity bits from the decoded data.
the
```
00155557 00155ff7 001d5f5f 00155557 00155557 0015f557 001dd57f 001557ff 00155557 0015575f 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
```
is the raw data send in 22 bit encode in hexa. But I am not receive the original data.
I decode like this:
```
items = (rmt_item32_t*)xRingbufferReceive(rrc->rb, &length, ticks_to_wait);
if (items) {
for (size_t i = 0; i < length / 4; ++i)
{
ESP_LOGD(TAG, "\trmt rx item %02d: duration0: %d level0: %d duration1: %d level1: %d", i, items.duration0, items.level0, items.duration1, items.level1);
fill_bits(ctx, items.duration0, items.level0);
fill_bits(ctx, items.duration1, items.level1);
}
vRingbufferReturnItem(rrc->rb, (void*)items);
ESP_LOGD(TAG, "\trx is complete byte_num=%d", rrc->byte_num);
printf("rmt rx ");
for (int i = 0; i < rrc->byte_num; ++i)
printf("%02x ", rrc->bytes);
printf("\n\n");
}
static void fill_bits(rmt_uart_contex_t* ctx, uint32_t duration, uint32_t level)
{
rmt_uart_contex_rx_t* rrc = &ctx->rmt_uart_contex_rx;
rmt_uart_contex_rx_t* rrc = &ctx->rmt_uart_contex_rx;
int rmt_bit_numbers = round_closest(duration, ctx->rmt_bit_len);
// all remaining bits are high
if (rmt_bit_numbers == 0 && level) {
rmt_bit_numbers = 11 - rrc->bit_num;
}
int from = rrc->bit_num;
int to = rrc->bit_num + rmt_bit_numbers;
for (int j = from; j < to; ++j) {
rrc->bit_num++;
rrc->raw_data |= (level << j);
if (rrc->bit_num == 11) {
rrc->raw_data >>= 1;
rrc->raw_data &= 0x00FF;
rrc->bytes[rrc->byte_num] = rrc->raw_data;
ESP_LOGD(TAG, "\trmt rx data=%d", rrc->raw_data);
rrc->byte_num++;
rrc->bit_num = 0;
rrc->raw_data = 0;
}
}
```
I tested the github code with normal UART 19200 8N the code work fine. The code above modified for 22 bit data