Select Class

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
cooper
Posts: 23
Joined: Mon Oct 20, 2014 8:40 am

Select Class

Post by cooper » Mon Jan 26, 2015 10:55 am

Hello,

Excuse my ignorance but what is the difference between using uart.any() and the Select Class: http://docs.micropython.org/en/latest/l ... ule-select? To me it seems like a long winded way to achieve the same results?
Please correct me if I am wrong.

Thanks, Cooper

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Select Class

Post by blmorris » Mon Jan 26, 2015 2:16 pm

The uart.any() method tells you if there are characters waiting in the buffer for a specific serial port; the 'uart' object could be any one of 6 hardware serial ports on the pyboard or the USB_VCP virtual comm port.
As I understand it, the Select class allows you to register a set of these 6 available UART ports along with the USB_VCP port for polling through a single object - a single point to listen to a set of data streams, rather than polling each initialized UART separately.
(Disclaimer - I haven't tried to use Select in my code yet, but that is how I understand it.)

-Bryan

Post Reply