My point is: read() only returns anything when the buffer has 120 bytes.
Before, nothing coes back.
In my case, I'm using a extremely simple protocol, 8 bytes long, 110bps, half-duplex.
I have to read byte by byte and parse the frame on the fly and sincronize.
Code: Select all
def test_rx():
uart = UART(2, baudrate=110, timeout_char=1)
print(uart)
frame = []
while True:
buffer = uart.read(1)
if buffer:
for byte in buffer:
frame.append(byte)
if len(frame) == 8:
uart.write("U")
line = ""
for byte in frame:
line += "{} ".format(str(byte))
print(line)
frame = []
I can see in the MP source code that flow control is off.
We start by populating a uart_config_t structure instance. This provides the core
settings for a UART we want to use. An example might be:
Code: Select all
uart_config_t myUartConfig;
myUartConfig.baud_rate = 115200;
myUartConfig.data_bits = UART_DATA_8_BITS;
myUartConfig.parity = UART_PARITY_DISABLE;
myUartConfig.stop_bits = UART_STOP_BITS_1;
myUartConfig.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
myUartConfig.rx_flow_ctrl_thresh = 120;[/i]