RS485 passive sniffer (RX-only) driver.
More...
#include "driver/uart.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Go to the source code of this file.
RS485 passive sniffer (RX-only) driver.
- Author
- Abanoub Salah
- Does not transmit or control DE/RE lines
- Passively listens to bus traffic using UART RX
- Provide a task that provide events as they come to provided callback
◆ RS485_DRIVER_TASK_BUFFER_SIZE
| #define RS485_DRIVER_TASK_BUFFER_SIZE (256U) |
◆ RS485_DRIVER_TASK_CPU_AFFINITY
| #define RS485_DRIVER_TASK_CPU_AFFINITY (0U) |
◆ RS485_DRIVER_TASK_NAME
| #define RS485_DRIVER_TASK_NAME ("RS485_DRV") |
◆ RS485_DRIVER_TASK_NOTIFY_STOP_BIT
| #define RS485_DRIVER_TASK_NOTIFY_STOP_BIT (1U << 0U) |
◆ RS485_DRIVER_TASK_PRIORITY
| #define RS485_DRIVER_TASK_PRIORITY (16U) |
◆ RS485_DRIVER_TASK_STACK_DEPTH
| #define RS485_DRIVER_TASK_STACK_DEPTH (4096U) |
◆ rs485_driver_event_flags_t
RS485 driver event flags enum.
| Enumerator |
|---|
| RS485_DRIVER_EVENT_FLAG_DATA | Data flag
|
| RS485_DRIVER_EVENT_FLAG_RX_TIMEOUT | Rx timeout flag
|
| RS485_DRIVER_EVENT_FLAG_OVERFLOW | Overflow flag
|
| RS485_DRIVER_EVENT_FLAG_PARITY | Parity flag
|
◆ rs485_driver_deinit()
De-initialize RS485 driver.
- Parameters
-
| rs485_drv_ptr | Pointer to RS485 driver structure |
◆ rs485_driver_get_bits_count()
Get frame bits count.
- Parameters
-
| rs485_drv_ptr | Pointer to RS485 driver structure |
- Returns
- uint8_t Frame bits count
- Note
- Only call this function after driver initialization otherwise return is unpredictable
◆ rs485_driver_init()
Initialize RS485 driver.
- Parameters
-
| rs485_drv_ptr | Pointer to RS485 driver structure |
| config_ptr | Pointer to RS485 driver configuration structure |
- Returns
- esp_err_t Initialize result
- Return values
-
| ESP_OK | Initialize success |
| ESP_FAIL | Initialize fail |
| ESP_ERR_INVALID_ARG | Provided invalid argument(s) |
| ESP_ERR_NO_MEM | No available memory for resource allocation |
- Note
- Driver doesn't use Tx pin as it act as a sniffer only
- Pin is set as UART_PIN_NO_CHANGE
- Mode is set to UART_MODE_RS485_APP_CTRL
-
UART RX FIFO FULL threshold is set to 128. For typical Modbus 8 to 256 Bytes is typical 128 characters is a practical value in-between and less than driver's event data buffer
-
UART RX timeout threshold is set to 4 closest integer to 3.5 characters Inter-frame timeout of practical Modbus transaction