-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Ethernet : Added support in ethernet #10124
Conversation
Related to nuttx pull request |
A couple initial thoughts. Running network manager as a task is a huge waste of memory I don't have a better solution in mind at the moment, but spreading network configuration across parameters feels pretty awkward. Do you actually need it to be runtime configurable like this, or is it just a convenient way to make it persistent? |
@dagar network manager does run as a task, but after setting all the Ethernet related it exits immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garfieldG This is cool! Thank you.
@@ -0,0 +1,241 @@ | |||
/**************************************************************************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this structured this way?
This seems like it should a new file in the common stm32 board code and called from init function based on #define values for IP and MAC. A wrapper systemcmd could be added and a init script call could be done from rcS or read from SD card file to set mac, ip etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davids5
Hi,
So some thoughts after reading your comment.
There is no need to add a file in order to use "#define" values , the define values are already used, the network manager only uses the parameters values, if someone wants to use the "#define" values then there's no need in network manager or similar.
The "#define" values are set in defconfig:
-CONFIG_NSH_IPADDR
-CONFIG_NSH_DRIPADDR
-CONFIG_NSH_NETMASK
-CONFIG_NSH_MACADDR
SD card can be changed or moved while parameters are per plane.
From my experience it is easy to use the Ethernet related values as parameters.
You can change it very easily, no need to take the SD off, change it and put it back.
If you're not sure what the IP is (or some other value) you can always look in a program like QGC, and again no need to read values from a file saved on the SD.
It's quick and easy to use (especially in case of more than one person using the same plane and more than one plane) and I do think that the values should be changed through parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garfieldG - Thank you for the perspective. I always am looking from a deeply embedded point of view at the cost of a feature set on resources. So it is good from me to have your perspective from a use-case perspective. Thank you for the changes for the defines.
@@ -2702,7 +2711,11 @@ MavlinkReceiver::receive_start(pthread_t *thread, Mavlink *parent) | |||
param.sched_priority = SCHED_PRIORITY_MAX - 80; | |||
(void)pthread_attr_setschedparam(&receiveloop_attr, ¶m); | |||
|
|||
#ifdef CONFIG_NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better structured as
#if !defined(CONFIG_NET)
# define NET_ADDED_STACK 0
# else
# define NET_ADDED_STACK 1360
#endif
At the top of file or header
and use
pthread_attr_setstacksize(&receiveloop_attr, PX4_STACK_ADJUSTED(2840+NET_ADDED_STACK ));
here
src/modules/mavlink/mavlink_main.cpp
Outdated
@@ -2683,7 +2763,11 @@ Mavlink::start(int argc, char *argv[]) | |||
px4_task_spawn_cmd(buf, | |||
SCHED_DEFAULT, | |||
SCHED_PRIORITY_DEFAULT, | |||
#ifdef CONFIG_NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as comment as below - in general where possible 1 ifdef to configure the deltas and then no ifdefs in the code is a cleaner approach.
@davids5 |
Parameters make total sense, yes. |
src/modules/mavlink/mavlink_main.cpp
Outdated
break; | ||
|
||
//multicast | ||
#if defined(CONFIG_NET_IGMP) && defined(CONFIG_NET_ROUTE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is NuttX specific but probably also works on Linux. So probably best to do under one define (as @davids5 suggested).
src/modules/mavlink/mavlink_main.cpp
Outdated
@@ -243,7 +249,7 @@ Mavlink::Mavlink() : | |||
_rate_tx(0.0f), | |||
_rate_txerr(0.0f), | |||
_rate_rx(0.0f), | |||
#ifdef __PX4_POSIX | |||
#if defined(CONFIG_NET) || defined(__PX4_POSIX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new define __PX4_NETWORK
and setting that above for when NuttX networking is enabled or POSIX is available is cleaner.
src/modules/mavlink/mavlink_main.cpp
Outdated
|
||
ret = sendto(_socket_fd, _network_buf, _network_buf_len, 0, | ||
(struct sockaddr *)&_src_addr, sizeof(_src_addr)); | ||
#ifdef CONFIG_NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this also true for POSIX? The source address has to be initialized.
@dagar Would you want to help this to get to completion so you can leverage this as well on your F7 unit? |
@davids5 |
@LorenzMeier Thanks! Actually not sure where should I create the new define. Maybe whenever __PX4_POSIX is defined then define CONFIG_NET? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @garfieldG ! I'm interested to know the general resource usage of the NuttX networking stack. On what board are you testing this?
What is the CPU load?
By how much does RAM usage increase?
|
||
void NetworkManager::task_main() | ||
{ | ||
_param_sub = orb_subscribe(ORB_ID(parameter_update)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, the initial thought was to enable IP changes after startup, but it was canceled afterwards due to problems we encountered
|
||
int NetworkManager::start(int argc, char *argv[]) | ||
{ | ||
_taskmap_id = px4_task_spawn_cmd("network_manager", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT, 1200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, as the task exits right after configuration. Can you directly execute the config inside the main task? Or is it something that takes a long time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's needed.
It's here 'cause NetworkManager was supposed to be a running task that can handle changes with parameters, but it was changed later on.
* @min 0 | ||
* @max 255 | ||
*/ | ||
PARAM_DEFINE_INT32(ETH_IP_ADDR_0, 192); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use a single parameter for the IP and the Gateway? Both are 4 bytes each and fit into a single parameter.
We should then make sure QGC learns how to display IP addresses (@DonLakeFlyer @dogmaphobic ) and add the metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was structured like this because of the GUI and the fact that one parameter can be a very long number and it seemed like less comfortable solution. Do you think it's better to use a single parameter? It was a real conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fact that one parameter can be a very long number and it seemed like less comfortable solution.
Yes exactly. That's why we should to extend QGC so that it shows the IP in the form 192.168.1.1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there's a problem doing so...
Let's say we wan't to change the IP parameter value to 192.168.0.1 with the param set command.
The actual value that will be stored is 127.255.255.255 (LONG_MAX), I suspect the problem is with the do_set function that uses strtol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! So we would need to fix the parameters. But that would cause more bloat to go to 64 bits (unless the union already is that big - IDNR)
I think this further reinforces @dagar
#10124 (comment) and also suggest the parameters need some design effort for isolation (things stores but not user facing) and scalability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should then make sure QGC learns how to display IP addresses (@DonLakeFlyer @dogmaphobic ) and add the metadata.
That would require a parameter type of IP address to be added to mavlink and then flow through to QGC changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not mac using 2 parameters?
We can do that too but it's more than 4 bytes. A 64 bit param type would be helpful.
For the param set
we can easily extend it to accept the form x.y.z.w
.
That would require a parameter type of IP address to be added to mavlink and then flow through to QGC changes.
Why mavlink? We can do it through the unit in the param xml metadata. It would still be an INT32 as underlying type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! So we would need to fix the parameters. But that would cause more bloat to go to 64 bits
Why not just using uint32? why 64?
For the param set we can easily extend it to accept the form x.y.z.w.
I think this is my preferred idea, much more user friendly
We can do that too but it's more than 4 bytes. A 64 bit param type would be helpful.
Yes, it would be. But if for some reason we don't want a 64 bit param we can use 2 32 bit param for mac, do you think it's a good idea? or is it just another thing that will complicate the user experience?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if for some reason we don't want a 64 bit param we can use 2 32 bit param for mac, do you think it's a good idea? or is it just another thing that will complicate the user experience?
I think that would complicate the user experience too much.
I don't think parameters really make sense for this kind of configuration, but it's our only option at the moment. We need something like a mavlink message to configure the network interface atomically with a different storage backend internally. Something for another day... I'll test this on the F7 board I have with ethernet. |
@bkueng I tested it on a costume board. |
Seeing that the CONFIGxxx come from the defconfig and nuttx has to be built with the config, We have 2 options. 1) maintain and carry a separate board config target with |
As discussed on the dev call I propose splitting off the mavlink changes into a separate PR we can test, review, merge ASAP and the network_manager discussion can continue here. |
-new network_manager module gives the ability to control ethernet related (as ip,mac and etc...) through parameters
52ab1b2
to
a438f0e
Compare
8f9db90
to
03a56a2
Compare
@davids5 what's the status here? |
@julianoes IIRC @dagar had an issue with the use of param for the IP address, but no other solutions was developed. |
When I read it I see that @garfieldG 's questions never got answered. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
FYI @dinomani |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
-new network_manager module gives the ability to control Ethernet related (as ip,mac and etc...) through parameters
Additional context
-To use network_manager in rcS add the line "network_manager start" before mavlink