Skip to content

Check for OOBs on background #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 26, 2018
Merged

Conversation

VeijoPesonen
Copy link
Contributor

Description

Check for OOBs on background. Spawns a thread for that purpose.

Pull request type

[X] Fix
[] Refactor
[] Target update
[] Functionality change
[] Breaking change

char status[5];
if (_parser.recv("%4[^\"]\n", status)) {
if (strcmp(status, " s...\n") == 0) {
; //TODO maybe do something here, or not...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the whole reason for this OOB handler if it does not do anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making people aware there are this kind of events which might be raised. And especially to report an error if some new firmware introduces new messages on which we are to react.

}
} else {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_EBADMSG), \
"ESP8266::_oob_busy: busy doing what?\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the value of this error message. Messages should be targeted to users. So don't ask users what the ESP is doing.
Instead report that ESP is reporting busy status.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could change to something like "unrecognized AT busy state"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be more informative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be I have either bug on the code or there really is some unrecognized busy state as I was able to trigger one from those two code paths - unintentionally:

[1539777313.37][CONN][RXD] ++ MbedOS Error Info ++
[1539777313.41][CONN][RXD] Error Status: 0x8008004A Code: 74 Module: 8
[1539777313.47][CONN][RXD] Error Message: ESP8266::_oob_busy: busy doing what?
[1539777313.48][CONN][RXD] 
[1539777313.49][CONN][RXD] Location: 0x7FF1
[1539777313.51][CONN][RXD] Error Value: 0x0
[1539777313.61][CONN][RXD] Current Thread: Id: 0x2000434C Entry: 0x14607 StackSize: 0x1000 StackMem: 0x20004390 SP: 0x20005048 
[1539777313.70][CONN][RXD] For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x8008004A
[1539777313.72][CONN][RXD] -- MbedOS Error Info --

@SeppoTakalo
Copy link
Contributor

Change the processing to use the global event queue (after you have got rid of 2s timeout).
Other that that, it looks OK.

@VeijoPesonen VeijoPesonen force-pushed the feature-bg-network_status_thread branch from e1a7f83 to 7b978e9 Compare October 22, 2018 07:14
@VeijoPesonen
Copy link
Contributor Author

@SeppoTakalo, @kjbracey-arm , @marcuschangarm , @michalpasztamobica please review. Background processing changed to use global event queue instead of dedicated thread.


#include "events/EventQueue.h"
#include "events/mbed_shared_queues.h"
#include "rtos/Thread.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rtos/Thread.h is no longer needed when using the event queue, right?

Copy link
Contributor Author

@VeijoPesonen VeijoPesonen Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -104,6 +118,17 @@ int ESP8266Interface::connect(const char *ssid, const char *pass, nsapi_security
return connect();
}

void ESP8266Interface::_oob2geq()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geq?

As in.. global_event_queue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

Copy link
Contributor

@SeppoTakalo SeppoTakalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes still requested.
Otherwise looking OK.

README.md Outdated
@@ -52,6 +52,30 @@ Least one is expected to check are the following configuration parameters
}
```

To enable network status updates from the driver one must take Global EventQueue into use via app config file. Otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true..
mbed_event_queue(); will spawn a thread UNLESS "events.shared-dispatch-from-application": true

So this setting is just a possible memory optimization..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should remove this whole section.. Let the event queue spawn its own thread.. allow those who try to optimize memory to study this from Mbed OS documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Section dropped.

README.md Outdated
"esp8266.cts": "NC"
"esp8266.rx": "D0",
"esp8266.tx": "D1",
// Adds dispatch_forever() to your main-function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not add.. it requires

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Section dropped.

@SeppoTakalo
Copy link
Contributor

Looks good now.. Have you got any test results after this change?

@VeijoPesonen
Copy link
Contributor Author

There is need to increase the stack size for the thread spawned for global event queue. Unless this is done in app config stack overflow occurs with our netsocket test cases

"events.shared-stacksize": 1536

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented Oct 26, 2018

Test Results - AT firmware version 1.6.2 without HW flow control

netsocket-tcp

+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+
| target       | platform_name | test suite          | test case                          | passed | failed | result  | elapsed_time (sec) |
+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_CONNECT_INVALID          | 1      | 0      | OK      | 0.18               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST                 | 1      | 0      | OK      | 8.44               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_BURST           | 1      | 0      | OK      | 31.53              |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_BURST_NONBLOCK  | 1      | 0      | OK      | 31.1               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_NONBLOCK        | 1      | 0      | OK      | 5.28               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ENDPOINT_CLOSE           | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_OPEN_CLOSE_REPEAT        | 1      | 0      | OK      | 0.05               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_OPEN_LIMIT               | 1      | 0      | OK      | 0.22               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_100K                | 0      | 0      | ERROR   | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_100K_NONBLOCK       | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_TIMEOUT             | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_SEND_REPEAT              | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_SEND_TIMEOUT             | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_THREAD_PER_SOCKET_SAFETY | 1      | 0      | OK      | 5.07               |
+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+

netsocket-udp

+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite          | test case                         | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST                | 1      | 0      | OK     | 4.41               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_BURST          | 1      | 0      | OK     | 61.36              |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_BURST_NONBLOCK | 1      | 0      | OK     | 62.71              |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_NONBLOCK       | 1      | 0      | OK     | 8.92               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_OPEN_CLOSE_REPEAT       | 1      | 0      | OK     | 0.06               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_OPEN_LIMIT              | 1      | 0      | OK     | 0.21               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_INVALID          | 1      | 0      | OK     | 2.08               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_REPEAT           | 0      | 0      | ERROR  | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_TIMEOUT          | 0      | 1      | FAIL   | 9.9                |
+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+

network-interface

+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite              | test case                         | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_CONN_DISC_REPEAT | 1      | 0      | OK     | 55.22              |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS           | 1      | 0      | OK     | 58.36              |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS_GET       | 1      | 0      | OK     | 57.2               |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS_NONBLOCK  | 1      | 0      | OK     | 55.23              |
+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented Oct 26, 2018

Test Results - AT firmware version 1.7.0 with HW flow control

netsocket-tcp

Take a note how much longer it takes to execute the TCP test cases with newer firmware/my driver changes. I should address those issues in another PR.

+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+
| target       | platform_name | test suite          | test case                          | passed | failed | result  | elapsed_time (sec) |
+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_CONNECT_INVALID          | 1      | 0      | OK      | 0.29               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST                 | 1      | 0      | OK      | 10.85              |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_BURST           | 1      | 0      | OK      | 270.96             |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_BURST_NONBLOCK  | 1      | 0      | OK      | 310.26             |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ECHOTEST_NONBLOCK        | 1      | 0      | OK      | 42.88              |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_ENDPOINT_CLOSE           | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_OPEN_CLOSE_REPEAT        | 1      | 0      | OK      | 0.07               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_OPEN_LIMIT               | 1      | 0      | OK      | 0.21               |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_100K                | 1      | 0      | OK      | 182.72             |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_100K_NONBLOCK       | 1      | 0      | OK      | 158.44             |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_RECV_TIMEOUT             | 1      | 0      | OK      | 6.7                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_SEND_REPEAT              | 0      | 0      | ERROR   | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_SEND_TIMEOUT             | 0      | 0      | SKIPPED | 0.0                |
| K64F-GCC_ARM | K64F          | tests-netsocket-tcp | TCPSOCKET_THREAD_PER_SOCKET_SAFETY | 1      | 0      | OK      | 29.14              |
+--------------+---------------+---------------------+------------------------------------+--------+--------+---------+--------------------+

netsocket-udp

+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite          | test case                         | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST                | 1      | 0      | OK     | 9.35               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_BURST          | 1      | 0      | OK     | 27.29              |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_BURST_NONBLOCK | 1      | 0      | OK     | 27.92              |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_ECHOTEST_NONBLOCK       | 1      | 0      | OK     | 10.24              |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_OPEN_CLOSE_REPEAT       | 1      | 0      | OK     | 0.05               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_OPEN_LIMIT              | 1      | 0      | OK     | 0.23               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_INVALID          | 1      | 0      | OK     | 0.09               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_REPEAT           | 1      | 0      | OK     | 0.81               |
| K64F-GCC_ARM | K64F          | tests-netsocket-udp | UDPSOCKET_SENDTO_TIMEOUT          | 1      | 0      | OK     | 0.14               |
+--------------+---------------+---------------------+-----------------------------------+--------+--------+--------+--------------------+

network-interface

+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+
| target       | platform_name | test suite              | test case                         | passed | failed | result | elapsed_time (sec) |
+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_CONN_DISC_REPEAT | 1      | 0      | OK     | 54.26              |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS           | 1      | 0      | OK     | 51.43              |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS_GET       | 1      | 0      | OK     | 50.24              |
| K64F-GCC_ARM | K64F          | tests-network-interface | NETWORKINTERFACE_STATUS_NONBLOCK  | 1      | 0      | OK     | 50.25              |
+--------------+---------------+-------------------------+-----------------------------------+--------+--------+--------+--------------------+

@VeijoPesonen VeijoPesonen force-pushed the feature-bg-network_status_thread branch from dce922a to d1d84ee Compare October 26, 2018 10:53
@VeijoPesonen
Copy link
Contributor Author

@SeppoTakalo fixup commits squashed. Do you agree that those performance issues with the newer firmware can be addressed in another PR?

@SeppoTakalo
Copy link
Contributor

The change kind of looks good, but the performance is horrible. 10x slower on some test cases.

@VeijoPesonen
Copy link
Contributor Author

VeijoPesonen commented Oct 26, 2018

The performance of the driver for the newer firmware hasn't ever been what it is supposed to be. The undersigned is to be blamed for that but corrective actions are what I'm going to be working with next.

@VeijoPesonen VeijoPesonen merged commit 1375c89 into master Oct 26, 2018
@VeijoPesonen VeijoPesonen deleted the feature-bg-network_status_thread branch October 26, 2018 11:56
@marcuschangarm
Copy link
Contributor

Man, you weren't kidding about that performance degradation! 😨

@VeijoPesonen
Copy link
Contributor Author

@marcuschangarm PR ARMmbed/mbed-os#8598 should improve the situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants