Skip to content
Discussion options

You must be logged in to vote

There was a problem with my suggestion, in that a timeout was occurring in the main loop. Try this:

from machine import UART
from binascii import hexlify
from time import sleep_ms

uart = UART(1, baudrate=9600, tx=4, rx=3, bits=8, parity=None, stop=1, timeout=50, timeout_char=50)

for _ in range(100):
    while uart.read(1) is not None:
        pass
    while True:
        frame = uart.read(23)
        if frame is not None:
            print(hexlify(frame))
        else:
            print(frame)
        sleep_ms(50)  # Prevent timeout on next pass
        break

This should give better timing margins than setting the timeout to 70ms.

Replies: 8 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@ejgeiger
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ejgeiger
Comment options

@peterhinch
Comment options

Answer selected by ejgeiger
Comment options

You must be logged in to vote
4 replies
@ejgeiger
Comment options

@GitHubsSilverBullet
Comment options

@peterhinch
Comment options

@GitHubsSilverBullet
Comment options

Comment options

You must be logged in to vote
2 replies
@ejgeiger
Comment options

@shariltumin
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants