ESP32

ESP32, UART, uart_nonblocking_select

CoyoteUgly 2018. 8. 19. 21:19

ESP32, UART, uart_nonblocking_select



0. 참고 사이트


1. 모듈


2. 보드 연결

UART2 line를 사용합니다.
Tx 17, Rx 16


3. 소스 설명

기본 소스가 blocking 모드이기 때문에
아래 코드를 추가하여 non-blocking 모드로 동작합니다.

 // non-blocking
    int flags = fcntl(fd, F_GETFL, 0);
    fcntl(fd, F_SETFL, flags | O_NONBLOCK);


4. 소스

https://github.com/sglee0223/esp32/tree/master/uart_nonblocking_select


5. 결과 확인

stm32f1 보드가 500ms마다 Tx를 하면
select 함수를 통해 Rx하고 Tx를 합니다.