lwIP - A Lightweight TCP/IP stack - Bugs: bug #59049, MQTT in FreeRTOS tasks give error...
You are not allowed to post comments on this tracker with your current authentication level.
bug #59049: MQTT in FreeRTOS tasks give error on TCP-write/output
Submitter: | Andre <klaasvortex> | ||
Submitted: | Tue 01 Sep 2020 11:48:49 AM UTC | ||
Category: | Contrib | Severity: | 3 - Normal |
Item Group: | Faulty Behaviour | Status: | None |
Privacy: | Public | Assigned to: | None |
Open/Closed: | Open | Planned Release: | None |
lwIP version: | 2.1.1 |
Thu 01 Oct 2020 09:49:23 AM UTC, comment #4: |
Andre <klaasvortex> |
Wed 30 Sep 2020 05:58:18 PM UTC, comment #3: Hi David, Andre,
|
Dejan <dejandigitex> |
Fri 18 Sep 2020 01:35:39 PM UTC, comment #2: Hi David,
|
Andre <klaasvortex> |
Fri 18 Sep 2020 09:58:18 AM UTC, comment #1: Hi Andre,
|
David GIRAULT <dgirault> |
Tue 01 Sep 2020 11:48:49 AM UTC, original submission:
When using MQTT to sent data from seperate threads (FreeRTOS) I got errors on LWIP. (and sometimes deadlocks in loops)
|
Andre <klaasvortex> |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Powered by Savane 3.13-3230.
Corresponding source code
Hi Dejan,
First I am not an expert, so keep that in mind.
I think the problem can be simular to mine, since crossing thread on LWIP can/will mangle up the tcp/ip stack. It can take a while but it will.
First the TCP/IP is a REAL Freertos thread, lets call this task0, but DHCP is running on the LWIP timers (which run in task0). This is also true for HTTPD. So what I did is running the MQTT thread in a lwip timer, so MQTT runs from task0. This solved my troubles.
There are CYCLIC timers in LWIP, but they are not accesibly to 'user-program'. But you can add them into the source code.
I do prefer my one-shot timer, since it will not touch the LWIP code.
---------------------------
So for example. Something like this.
main()
{
// This will start the MQTT System after 15 seconds
sys_timeout(15000, MQTT_Task, NULL);
}
// So this is the task that does the workload and it will restart every period
void MQTT_Task(void *arg)
{
err_t err;
(void) arg;
// RESTART THE TASK
tMS reloadTimer = 1000;
if (dns_gethostbyname( dMQTT_SERVER_NAME, &mqttTask.serverIP, MQTTServerFound, NULL) == ERR_OK)
{
switch (mqttTask.status)
{
case eMQTT_INIT:
mqttTask.counterMS = dMS(0);
mqtt_disconnect(mqttTask.client);
err = mqtt_client_connect(mqttTask.client, &mqttTask.serverIP, dMQTT_PORT, MQTT_ConnectionCB, 0, &ci);
if(err == ERR_ISCONN)
}