1

For UART communication on Raspberry Pi one can write a program in Python with the pyserial package or a program in C. Pyserial requires Threading for non-blocking UART, while C libraries allow to use a single core CPU. Thus for Raspberry pi Zero only C program can achieve the non-blocking UART. Is this correct?

5

This is not correct. Even single core CPUs are capable of running multiple processes giving them short time window to run and then switching to next process. Also both Python and C programs are capable of using the same services from system so you can achieve the same from both.

  • 1
    "Also both Python and C programs are capable of using the same services from system so you can achieve the same from both." -> This is not exactly true; there are some restrictions on python due to its nature, e.g., to do with threading. – goldilocks Jan 11 at 16:09
1

You can easily implement non-blocking UART in Python without threads using in_waiting:

in_waiting

Getter: Get the number of bytes in the input buffer

Just don't read more bytes than in_waiting tells you are available, and your code will never block.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.