Porting mros2 as an Mbed library.

Dependents:   mbed-os-example-mros2 example-mbed-mros2-sub-pose example-mbed-mros2-pub-twist example-mbed-mros2-mturtle-teleop

Committer:
smoritaemb
Date:
Sat Mar 19 09:23:37 2022 +0900
Revision:
7:c80f65422d99
Parent:
0:580aba13d1a1
Merge test_assortment_of_msgs branch.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smoritaemb 0:580aba13d1a1 1 /*
smoritaemb 0:580aba13d1a1 2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
smoritaemb 0:580aba13d1a1 3 * All rights reserved.
smoritaemb 0:580aba13d1a1 4 *
smoritaemb 0:580aba13d1a1 5 * Redistribution and use in source and binary forms, with or without modification,
smoritaemb 0:580aba13d1a1 6 * are permitted provided that the following conditions are met:
smoritaemb 0:580aba13d1a1 7 *
smoritaemb 0:580aba13d1a1 8 * 1. Redistributions of source code must retain the above copyright notice,
smoritaemb 0:580aba13d1a1 9 * this list of conditions and the following disclaimer.
smoritaemb 0:580aba13d1a1 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
smoritaemb 0:580aba13d1a1 11 * this list of conditions and the following disclaimer in the documentation
smoritaemb 0:580aba13d1a1 12 * and/or other materials provided with the distribution.
smoritaemb 0:580aba13d1a1 13 * 3. The name of the author may not be used to endorse or promote products
smoritaemb 0:580aba13d1a1 14 * derived from this software without specific prior written permission.
smoritaemb 0:580aba13d1a1 15 *
smoritaemb 0:580aba13d1a1 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
smoritaemb 0:580aba13d1a1 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
smoritaemb 0:580aba13d1a1 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
smoritaemb 0:580aba13d1a1 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
smoritaemb 0:580aba13d1a1 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
smoritaemb 0:580aba13d1a1 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
smoritaemb 0:580aba13d1a1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
smoritaemb 0:580aba13d1a1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
smoritaemb 0:580aba13d1a1 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
smoritaemb 0:580aba13d1a1 25 * OF SUCH DAMAGE.
smoritaemb 0:580aba13d1a1 26 *
smoritaemb 0:580aba13d1a1 27 * This file is part of the lwIP TCP/IP stack.
smoritaemb 0:580aba13d1a1 28 *
smoritaemb 0:580aba13d1a1 29 * Author: Adam Dunkels <adam@sics.se>
smoritaemb 0:580aba13d1a1 30 *
smoritaemb 0:580aba13d1a1 31 */
smoritaemb 0:580aba13d1a1 32
smoritaemb 0:580aba13d1a1 33 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
smoritaemb 0:580aba13d1a1 34
smoritaemb 0:580aba13d1a1 35 #include "lwip/opt.h"
smoritaemb 0:580aba13d1a1 36
smoritaemb 0:580aba13d1a1 37 #include "lwip/netif.h"
smoritaemb 0:580aba13d1a1 38 #include "lwip/ip_addr.h"
smoritaemb 0:580aba13d1a1 39 #include "lwip/tcpip.h"
smoritaemb 0:580aba13d1a1 40 #include "../pcapif.h"
smoritaemb 0:580aba13d1a1 41 #include "examples/example_app/default_netif.h"
smoritaemb 0:580aba13d1a1 42
smoritaemb 0:580aba13d1a1 43 static struct netif netif;
smoritaemb 0:580aba13d1a1 44
smoritaemb 0:580aba13d1a1 45 #if LWIP_IPV4
smoritaemb 0:580aba13d1a1 46 #define NETIF_ADDRS ipaddr, netmask, gw,
smoritaemb 0:580aba13d1a1 47 void init_default_netif(const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw)
smoritaemb 0:580aba13d1a1 48 #else
smoritaemb 0:580aba13d1a1 49 #define NETIF_ADDRS
smoritaemb 0:580aba13d1a1 50 void init_default_netif(void)
smoritaemb 0:580aba13d1a1 51 #endif
smoritaemb 0:580aba13d1a1 52 {
smoritaemb 0:580aba13d1a1 53 #if NO_SYS
smoritaemb 0:580aba13d1a1 54 netif_add(&netif, NETIF_ADDRS NULL, pcapif_init, netif_input);
smoritaemb 0:580aba13d1a1 55 #else /* NO_SYS */
smoritaemb 0:580aba13d1a1 56 netif_add(&netif, NETIF_ADDRS NULL, pcapif_init, tcpip_input);
smoritaemb 0:580aba13d1a1 57 #endif /* NO_SYS */
smoritaemb 0:580aba13d1a1 58 netif_set_default(&netif);
smoritaemb 0:580aba13d1a1 59 }
smoritaemb 0:580aba13d1a1 60
smoritaemb 0:580aba13d1a1 61 void
smoritaemb 0:580aba13d1a1 62 default_netif_poll(void)
smoritaemb 0:580aba13d1a1 63 {
smoritaemb 0:580aba13d1a1 64 #if !PCAPIF_RX_USE_THREAD
smoritaemb 0:580aba13d1a1 65 /* check for packets and link status*/
smoritaemb 0:580aba13d1a1 66 pcapif_poll(&netif);
smoritaemb 0:580aba13d1a1 67 /* When pcapif_poll comes back, there are not packets, so sleep to
smoritaemb 0:580aba13d1a1 68 prevent 100% CPU load. Don't do this in an embedded system since it
smoritaemb 0:580aba13d1a1 69 increases latency! */
smoritaemb 0:580aba13d1a1 70 sys_msleep(1);
smoritaemb 0:580aba13d1a1 71 #else /* !PCAPIF_RX_USE_THREAD */
smoritaemb 0:580aba13d1a1 72 sys_msleep(50);
smoritaemb 0:580aba13d1a1 73 #endif /* !PCAPIF_RX_USE_THREAD */
smoritaemb 0:580aba13d1a1 74 }
smoritaemb 0:580aba13d1a1 75
smoritaemb 0:580aba13d1a1 76 void
smoritaemb 0:580aba13d1a1 77 default_netif_shutdown(void)
smoritaemb 0:580aba13d1a1 78 {
smoritaemb 0:580aba13d1a1 79 /* release the pcap library... */
smoritaemb 0:580aba13d1a1 80 pcapif_shutdown(&netif);
smoritaemb 0:580aba13d1a1 81 }
smoritaemb 0:580aba13d1a1 82 #endif