Skip to content
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

net_info module - ping function #2854

Merged
merged 4 commits into from May 10, 2020
Merged

net_info module - ping function #2854

merged 4 commits into from May 10, 2020

Conversation

vsky279
Copy link
Contributor

@vsky279 vsky279 commented Jul 25, 2019

Fixes #1555.

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

This PR is created based on initial module by @wolfgangr with only few fixes. It seems to be pity to drop the work that has been done by @wolfgangr.
This version is working reliably in one of my applications so I think it is eligible to be merged into dev version.
Once reviewed I will squash these commits into one.
Actually can I do it just for the PR and have them separated in my branch?

@marcelstoer
Copy link
Member

Regardless of whether this will ever be merged...the CI build failed. Not sure if you have access to this https://travis-ci.org/nodemcu/nodemcu-firmware/jobs/563711700

net_info.c:14:22: fatal error: c_stdlib.h: No such file or directory
 #include "c_stdlib.h"
                      ^
compilation terminated.
../../Makefile:417: recipe for target '.output/eagle/debug/obj/net_info.o' failed
make[2]: *** [.output/eagle/debug/obj/net_info.o] Error 1
make[2]: Leaving directory '/home/travis/build/nodemcu/nodemcu-firmware/app/modules'
../Makefile:380: recipe for target '.subdirs' failed
make[1]: *** [.subdirs] Error 2
make[1]: Leaving directory '/home/travis/build/nodemcu/nodemcu-firmware/app'
Makefile:380: recipe for target '.subdirs' failed
make: *** [.subdirs] Error 2
make: Leaving directory '/home/travis/build/nodemcu/nodemcu-firmware'
The command "if [ "$OS" = "linux" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/ci-build-linux.sh; fi" exited with 1.

That is due to #2838.

@vsky279
Copy link
Contributor Author

vsky279 commented Jul 25, 2019

I will fix it when #2853 is solved. I can't compile now :-(

Copy link
Member

@nwf nwf left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution. Before this can be merged, I would like to see several changes to the module, not the least of which is that I would like to be able to have multiple ping requests going at once (as LwIP supports) and see proper C object life-cycle management.

app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
docs/en/modules/net_info.md Outdated Show resolved Hide resolved
docs/en/modules/net_info.md Outdated Show resolved Hide resolved
docs/en/modules/net_info.md Outdated Show resolved Hide resolved
docs/en/modules/net_info.md Outdated Show resolved Hide resolved
@vsky279 vsky279 force-pushed the ping branch 2 times, most recently from 58b19c0 to c520bef Compare July 26, 2019 19:14
@vsky279
Copy link
Contributor Author

vsky279 commented Jul 26, 2019

Regardless of whether this will ever be merged...the CI build failed. Not sure if you have access to this https://travis-ci.org/nodemcu/nodemcu-firmware/jobs/563711700

Ok, so at least it compiles now.

Nathan @nwf thanks for all suggestions. Progressively I will try to implement them. It will be pending for some while as I'm on another project now.

Stay tuned.

app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
@marcelstoer marcelstoer added this to the Next release milestone Sep 10, 2019
app/include/lwip/app/ping.h Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
app/modules/net_info.c Outdated Show resolved Hide resolved
@nwf
Copy link
Member

nwf commented Sep 12, 2019

Thank you for your continued work on this module. 👍

@TerryE
Copy link
Collaborator

TerryE commented May 4, 2020

would be great of that experience eventually led to an updated (or "finally released" actually) version of this page: https://github.com/nodemcu/nodemcu-firmware/wiki/%5BDRAFT%5D-How-to-write-a-C-module

@marcelstoer my thoughts entirely.

@vsky279
Copy link
Contributor Author

vsky279 commented May 6, 2020

Ok, so now we have very clean implementation of the net_info.ping() function.
It was redesigned with great help of @TerryE Terry (in fact Terry re-wrote it 😄).
That was great experience that improved substantially my understanding of C Lua programming. Thank you.

@vsky279 vsky279 mentioned this pull request May 6, 2020
4 tasks
@TerryE
Copy link
Collaborator

TerryE commented May 6, 2020

(in fact Terry re-wrote it smile).

That's too much attribution, IMO. We wouldn't be here without Lukáš doing the heavy lifting. Doing this exercise has really help me clarify some of my own thoughts. Thanks for your work.

@TerryE
Copy link
Collaborator

TerryE commented May 8, 2020

@nwf I think that this code in good to go now. My only Q is whether this one function merits its own module or should be just move it into net possibly with a NET_INFO_ENABLE option in user_config.h just in case we don't always want to compile in the ping code. What is your view?

@nwf
Copy link
Member

nwf commented May 8, 2020

I'd like it to be merged with net, available as net.ping(), possibly gated with NET_PING_ENABLE.

@marcelstoer
Copy link
Member

marcelstoer commented May 8, 2020

My only Q is whether this one function merits its own module or should be just move it into net

That has come up here and in the original issue #1555 a couple of times. I personally favor the latter with no extra option. I don't see why this should be gated and other stuff not.
The current net module is quite a large beast (server sockets, client sockets, TCP, UDP, DNS) that adding another function won't make much difference. If at some point someone feels motivated to split it into more manageable chunks then yes, go for it.

P.S. any extra y/n option will make a function unavailable to those who don't compile stuff themselves

@nwf
Copy link
Member

nwf commented May 8, 2020

@marcelstoer Well, merging with net and gating behind a default-on #define would be fine for web builders and leave the option for people trying to reduce firmware size. Still, I think you're right that just landing it in net is fine.

@TerryE
Copy link
Collaborator

TerryE commented May 8, 2020

@vsky279 can you drop the net_info module, ditto the separate doc file and modules define. Add your code and doc to net and the enabled NET_INFO_ENABLE option in user_config.h.

I'd like to merge this before I do my next tranche of fixes. Thanks.

@vsky279
Copy link
Contributor Author

vsky279 commented May 10, 2020

ping is a part of net module now. By default it is not included. NET_INFO_ENABLE needs to be defined in user_config.h.
I preserved ping implementation in separate net_info.c and net_info.h files. It seems cleaner to me then to have it directly in net.c. But let me know if you prefer latter option.

I was thinking about implementing a callback to the sent event as @TerryE suggested once. A second callback function as the fourth parameter of net.ping seems to me appropriate. What do you think?

@vsky279 vsky279 force-pushed the ping branch 2 times, most recently from 0e706d4 to 10c226f Compare May 10, 2020 09:48
@nwf
Copy link
Member

nwf commented May 10, 2020

I dislike the use of the name info for ping; can it be net_ping.c and NET_PING_ENABLE? Sorry for the long tail of cosmetic changes.

ETA: Another callback at the end seems like a perfectly reasonable addition, yes.

Changed to NET_PING_ENABLE macro
@vsky279
Copy link
Contributor Author

vsky279 commented May 10, 2020

All implemented and tested. Should be ready to be merged.

`net_info.md` no longer exists
@TerryE TerryE merged commit 2f527cf into nodemcu:dev May 10, 2020
@marcelstoer marcelstoer added this to the Next release milestone May 10, 2020
@vsky279 vsky279 deleted the ping branch May 10, 2020 20:17
@marcelstoer marcelstoer mentioned this pull request May 19, 2020
4 tasks
vsky279 added a commit to vsky279/nodemcu-firmware that referenced this pull request May 23, 2020
* Net_info module exposing ping function initial commit
* Ping as a part of net module
* Sent callback implemented
* Add NET_PING_ENABLE macro

Authored-by: vsky <blue205@centrum.cz> with support from TerryE
marcelstoer pushed a commit that referenced this pull request Jun 9, 2020
* Net_info module exposing ping function initial commit
* Ping as a part of net module
* Sent callback implemented
* Add NET_PING_ENABLE macro

Authored-by: vsky <blue205@centrum.cz> with support from TerryE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants