modbus_tcp

Make the tcp_pcb a global static variable
This commit is contained in:
2023-11-28 12:35:17 +01:00
parent 16f356de61
commit a61dcfb5c7

View File

@@ -30,6 +30,8 @@
char registers[MAX_REG];
static char* TAG = "Modbus_TCP"; // Tag used in logs
static struct tcp_pcb* modbus_pcb;
// Functions
static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err);
static err_t modbus_accept(void* arg, struct tcp_pcb* pcb, err_t err);
@@ -162,7 +164,6 @@ static err_t modbus_accept(void* arg, struct tcp_pcb* pcb, err_t err) {
* @brief Initializes the modbus tcp
*/
void modbus_init(void) {
struct tcp_pcb* modbus_pcb;
LOG_INFO(TAG, "Initializing\n");
modbus_pcb = tcp_new(); // Creating a new tcp pcb
tcp_bind(modbus_pcb, IP_ADDR_ANY, MODBUSPORT); // Bind the modbus_pcb to port 502