PID plotter component  1.0
ESP-IDF component for pid plotter
transport.h
Go to the documentation of this file.
1 #ifndef TRANSPORT_H
2 #define TRANSPORT_H
3 
4 #include <stdlib.h>
5 #include "udp_handler.h"
6 #include "json_handler.h"
7 #include "tcp_handler.h"
8 #include "logger.h"
9 #include "freertos/FreeRTOS.h"
10 #include "freertos/task.h"
11 #include "esp_system.h"
12 #include "freertos/queue.h"
13 #include "freertos/event_groups.h"
14 #include "freertos/semphr.h"
15 #include "esp_err.h"
16 #include "protocol_examples_common.h"
17 
19 QueueHandle_t pid_struct_queue;
20 SemaphoreHandle_t pid_const_read_write_mutex;
21 
22 #define MESSAGE_QUEUE_SIZE CONFIG_MESSAGE_QUEUE_SIZE
23 struct pid_terms
24 {
25  float current;
26  float error;
27  float P;
28  float I;
29  float D;
30 };
31 
32 struct data_recv
33 {
34  struct pid_terms data;
35  esp_err_t err;
36 };
37 
39 
40 esp_err_t init_queue(void);
41 void init_transport(void);
42 esp_err_t send_to_queue(struct pid_terms pid_data);
43 struct data_recv receive_from_queue(void);
44 void pid_transport();
45 void pid_const_transport();
46 struct pid_const pid_const_read();
47 #endif
float error
Definition: transport.h:26
void init_transport(void)
Initialises transport, i.e. connect to wifi.
Definition: transport.c:42
float D
Definition: transport.h:29
SemaphoreHandle_t pid_const_read_write_mutex
Definition: transport.h:20
void pid_const_transport()
Handles TCP client, which receives pid_constants from server, and parses the data and stores it in a ...
Definition: transport.c:151
Definition: transport.h:23
float P
Definition: transport.h:27
QueueHandle_t pid_struct_queue
Definition: transport.h:19
Definition: json_handler.h:30
TaskHandle_t pid_transport_handle
Definition: transport.h:18
float I
Definition: transport.h:28
struct pid_const pid_const_read()
Returns pid_const_data struct. Checks if the resource is blocked by mutex for writing or it is access...
Definition: transport.c:209
float current
Definition: transport.h:25
void pid_transport()
Handles UDP client, which sends pid_terms received through message queue.
Definition: transport.c:113
esp_err_t err
Definition: transport.h:35
struct pid_const pid_const_data
Definition: transport.h:38
Definition: transport.h:32
struct data_recv receive_from_queue(void)
Receive data from queue.
Definition: transport.c:83
TaskHandle_t pid_const_transport_handle
Definition: transport.h:18
esp_err_t send_to_queue(struct pid_terms pid_data)
Sends pid_data struct to message queue.
Definition: transport.c:57
esp_err_t init_queue(void)
Initialises message queue.
Definition: transport.c:10