Hi All,
This is the updated problem statement. I am doing a loopback in this case (in earlier scenario, I was using a different device which was sending the UART data).
Code: Select all
from machine import UART
import utime, uselect
u1 = UART(1, 9600, tx=17,rx=16, parity=None, stop=1, )
u2 = UART(2, 9600, tx=23,rx=22)
#wait = ((8*8)/9600)
while True:
u1.write('hello113')
# if(u2.any()!=0):
# poll = uselect.poll()
# poll.register(u2, uselect.POLLIN)
# print(poll.poll())
print(u2.any(), u2.read())
#utime.sleep_us(10000)
The REPL shows this repeatedly:
None
Code: Select all
0 None
0 None
0 None
0 None
0 None
0 None
0 None
120 b'hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113hello113'
0 None
0 None
0 None
0 None
0 None
0 None
The buffer sizes are 512 bytes. Also, I see that the HW FIFO size is 128 bytes. I am only writing 8 bytes, hence, there is no overflow. Also, I am reading it as many times as I write. whenever the uart RX FIFO gets any bytes, the function should output it. But, I am only seeing the read output 120 bytes together.
When I put utime.sleep() with wait time above a particular value, then the read function works as expected.
Am I missing something here? The data is not lost, means whatever u2 is receiving, it is getting stored somewhere (may be HW FIFO). But why the uart.read() is not outputting, if the data is stored somewhere ?
Regards