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

Enable SocketAPM to run on LwIP and add DDS support #25523

Merged
merged 13 commits into from
Nov 15, 2023

Conversation

magicrub
Copy link
Contributor

@magicrub magicrub commented Nov 13, 2023

Enable LwIP support to the existing SocketAPM so all libraries that use SocketAPM should auto-magically be able to work on SMT32 targets. More work to come to expand on this...

It also adds a new a pram DDS_IP which needs some param-name discussion because DDS_PORT is wrong.

This is on top of the Networking cleanup PR #25522

Thanks to @tridge and @Ryanf55

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Right now, it doesn't seem to work in SITL, the LWP thread exits.

image

@@ -65,6 +65,10 @@ const AP_Param::GroupInfo AP_DDS_Client::var_info[] {
// @User: Standard
AP_GROUPINFO("_PORT", 2, AP_DDS_Client, udp.port, 2019),

// @Group: _IP
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to add a description
"IP address of the DDS Agent"

Copy link
Contributor Author

@magicrub magicrub Nov 13, 2023

Choose a reason for hiding this comment

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

I don't think so.

Note, the _POPT docs are broken. Docs say "DDS_UDP_PORT" but code is "DDS_PORT". I'm in favor of removing the "UDP" part and have a different param control TCP/UDP server/client options

@magicrub
Copy link
Contributor Author

Right now, it doesn't seem to work in SITL, the LWP thread exits.

try ./waf configure --board sitl --enable-dds --enable-networking

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 13, 2023

Right now, it doesn't seem to work in SITL, the LWP thread exits.

try ./waf configure --board sitl --enable-dds --enable-networking

Thanks. It works on SITL. On Pixhawk 6X, I can't compile now. Cleaned out the build directory. This is on the latest hash c4580bcdad9bd0553655c1b557d89f839dabab6f.

$ ./waf configure --board Pixhawk6X --enable-dds --enable-networking
$  ./waf plane --upload
[  70/1155] Compiling libraries/APM_Control/AP_PitchController.cpp
In file included from ../../libraries/AP_HAL/board/chibios.h:3,
                 from ../../libraries/AP_HAL/AP_HAL_Boards.h:137,
                 from ../../libraries/AP_Scripting/AP_Scripting_config.h:3,
                 from ../../libraries/AC_AttitudeControl/AC_AttitudeControl_Multi_6DoF.cpp:1:
./hwdef.h:48: error: "AP_NETWORKING_ENABLED" redefined [-Werror]
   48 | #define AP_NETWORKING_ENABLED               TRUE
      | 
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors

In file included from ../../libraries/AP_HAL/board/chibios.h:3,
                 from ../../libraries/AP_HAL/AP_HAL_Boards.h:137,
                 from ../../libraries/AP_Math/control.h:3,
                 from ../../libraries/AC_WPNav/AC_WPNav_OA.cpp:1:
./hwdef.h:48: error: "AP_NETWORKING_ENABLED" redefined [-Werror]
   48 | #define AP_NETWORKING_ENABLED               TRUE
      | 
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors

In file included from ../../libraries/AP_HAL/board/chibios.h:3,
                 from ../../libraries/AP_HAL/AP_HAL_Boards.h:137,
                 from ../../libraries/AP_AHRS/AP_AHRS_config.h:3,
                 from ../../libraries/AP_AHRS/AP_AHRS.h:24,
                 from ../../libraries/APM_Control/AP_SteerController.cpp:20:
./hwdef.h:48: error: "AP_NETWORKING_ENABLED" redefined [-Werror]
   48 | #define AP_NETWORKING_ENABLED               TRUE
      | 
...

      | 
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors

In file included from ../../libraries/AP_HAL/board/chibios.h:3,
                 from ../../libraries/AP_HAL/AP_HAL_Boards.h:137,
                 from ../../libraries/AP_HAL/AP_HAL.h:6,
                 from ../../libraries/AP_Param/AP_Param.h:27,
                 from ../../libraries/AC_AttitudeControl/AC_AttitudeControl.h:7,
                 from ../../libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.h:6,
                 from ../../libraries/AC_AttitudeControl/AC_AttitudeControl_TS.h:6,
                 from ../../libraries/AC_AttitudeControl/AC_AttitudeControl_TS.cpp:20:
./hwdef.h:48: error: "AP_NETWORKING_ENABLED" redefined [-Werror]
   48 | #define AP_NETWORKING_ENABLED               TRUE
      | 
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors

Is this because both chibios_hwdef.py and AP_Networking_Config.h have AP_NETWORKING_ENABLED, but only one is protected?

@magicrub
Copy link
Contributor Author

It's messy at the moment. The enable-networking only applies to SITL. For chibos it's defined by the hwdef.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 13, 2023

It's messy at the moment. The enable-networking only applies to SITL. For chibos it's defined by the hwdef.

Thanks. To set up xinetd:

sudo apt install xinetd

change the settings

$ cat /etc/xinetd.d/echo
# default: off
# description: An xinetd internal service which echo's characters back to
# clients.
# This is the tcp version.
service echo
{
        disable         = yes
        type            = INTERNAL
        id              = echo-stream
        socket_type     = stream
        protocol        = tcp
        user            = root
        wait            = no
}

# This is the udp version.
service echo
{
        disable         = no
        type            = INTERNAL
        id              = echo-dgram
        socket_type     = dgram
        protocol        = udp
        user            = root
        wait            = yes
}

Restart xinetd:
sudo systemctl restart xinetd.service

Then, you can see port 7 open up:

$ sudo ss -nlpu '( sport = 7 )'
State                            Recv-Q                           Send-Q                                                     Local Address:Port                                                      Peer Address:Port                           Process                           
UNCONN                           0                                0                                                                      *:7                                                                    *:*                               users:(("xinetd",pid=2544,fd=5))                                         

And.

$ sudo lsof -n | grep xinetd
xinetd    236465                                 root  cwd       DIR              259,2       4096          2 /
xinetd    236465                                 root  rtd       DIR              259,2       4096          2 /
xinetd    236465                                 root  txt       REG              259,2     174496   48269488 /usr/sbin/xinetd
xinetd    236465                                 root  mem       REG              259,2      68552   48236927 /usr/lib/x86_64-linux-gnu/libresolv.so.2
xinetd    236465                                 root  mem       REG              259,2     182864   48241344 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
xinetd    236465                                 root  mem       REG              259,2     827936   48241327 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
xinetd    236465                                 root  mem       REG              259,2    2216304   48236911 /usr/lib/x86_64-linux-gnu/libc.so.6
xinetd    236465                                 root  mem       REG              259,2      22600   48262253 /usr/lib/x86_64-linux-gnu/libkeyutils.so.1.9
xinetd    236465                                 root  mem       REG              259,2      52016   48241317 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
xinetd    236465                                 root  mem       REG              259,2      18504   48261720 /usr/lib/x86_64-linux-gnu/libcom_err.so.2.1
xinetd    236465                                 root  mem       REG              259,2     338648   48241337 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
xinetd    236465                                 root  mem       REG              259,2     182912   48262775 /usr/lib/x86_64-linux-gnu/libtirpc.so.3.0.0
xinetd    236465                                 root  mem       REG              259,2     613064   48262503 /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0.10.4
xinetd    236465                                 root  mem       REG              259,2      93280   48262415 /usr/lib/x86_64-linux-gnu/libnsl.so.2.0.1
xinetd    236465                                 root  mem       REG              259,2     166280   48262655 /usr/lib/x86_64-linux-gnu/libselinux.so.1
xinetd    236465                                 root  mem       REG              259,2      44872   48262925 /usr/lib/x86_64-linux-gnu/libwrap.so.0.7.6
xinetd    236465                                 root  mem       REG              259,2     240936   48236905 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
xinetd    236465                                 root    0r      CHR                1,3        0t0          5 /dev/null
xinetd    236465                                 root    1r      CHR                1,3        0t0          5 /dev/null
xinetd    236465                                 root    2r      CHR                1,3        0t0          5 /dev/null
xinetd    236465                                 root    3r     FIFO               0,13        0t0    1107030 pipe
xinetd    236465                                 root    4w     FIFO               0,13        0t0    1107030 pipe
xinetd    236465                                 root    5u     IPv6            1078067        0t0        UDP *:echo 
xinetd    236465                                 root    7u     unix 0xffffa041d6e72200        0t0    1078062 type=DGRAM

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 13, 2023

#25522 is merged, please rebase this and fix conflicts.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 13, 2023

Next step: Add an AP_Networking_SITL as a backend. The UDP request/response doesn't work in DDS, but works with the test server. In order to have an easier time debugging, we would like to add a SITL backend. Tridge agrees we can merge this as-is even though DDS doesn't yet work.

libraries/AP_Networking/AP_Networking_Config.h Outdated Show resolved Hide resolved
@magicrub
Copy link
Contributor Author

@Ryanf55 rebased as requested.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 15, 2023

@Ryanf55 rebased as requested.

Let's merge it and solve DDS later. The UDP tests work; it might work fine for mavlink as-is.

@magicrub
Copy link
Contributor Author

I'm good with that. Mavlink support will be another can of worms that should be in a new PR

@magicrub magicrub merged commit d189730 into ArduPilot:master Nov 15, 2023
86 checks passed
@magicrub magicrub deleted the pr/networking6 branch November 15, 2023 20:43
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.

3 participants