[riot-notifications] [RIOT-OS/RIOT] drivers: net: add ethocan (Ethernet-over-CAN) driver (#10710)

benpicco notifications at github.com
Wed Jul 24 19:15:06 CEST 2019


benpicco commented on this pull request.

I'd suggest some small changes to auto_init so we can have more than one ethocan interface.
Should be pretty straightforward and better follow the conventions of the other drivers.

I still think this PR is useful for low-cost and reliable sensor connections, haven't gotten around to re-create the setup myself yet though.

It would be good if you added the documentation from the PR to the repository, especially that little wiring diagram would come in handy for anyone trying to re-create this.

Also some explanation on how this differs from `ethos` (point-to-point vs bus) would be good.

> +
+#ifndef ETHOCAN_BAUDRATE
+#define ETHOCAN_BAUDRATE      (115200)
+#endif
+
+/**
+ * @brief   Stacks for the MAC layer threads
+ */
+static char _netdev_eth_stack[ETHOCAN_MAC_STACKSIZE];
+
+void auto_init_ethocan(void)
+{
+    LOG_DEBUG("[auto_init_netif] initializing ethocan #0.\n");
+
+    /* setup netdev device */
+    ethocan_params_t p;

```suggestion
    for (unsigned i = 0; i < ARRAY_SIZE(ethocan_params); i++) {
        ethocan_setup(&ethocan[i], &ethocan_params[i]);
        gnrc_netif_ethernet_create(_netdev_eth_stack[i], ETHOCAN_MAC_STACKSIZE,
                                   ETHOCAN_MAC_PRIO, "ethocan", (netdev_t *)&ethocan[i]);
    }
```

> + * @author  Juergen Fitschen <me at jue.yt>
+ */
+
+#ifdef MODULE_ETHOCAN
+
+#include "log.h"
+#include "debug.h"
+#include "ethocan.h"
+#include "periph/uart.h"
+#include "periph/gpio.h"
+#include "net/gnrc/netif/ethernet.h"
+
+/**
+ * @brief global ethocan object
+ */
+ethocan_t ethocan;

```suggestion
static ethocan_t ethocan[ARRAY_SIZE(ethocan_params)];
```

> + * @brief   Define stack parameters for the MAC layer thread
+ * @{
+ */
+#define ETHOCAN_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
+#ifndef ETHOCAN_MAC_PRIO
+#define ETHOCAN_MAC_PRIO      (GNRC_NETIF_PRIO)
+#endif
+
+#ifndef ETHOCAN_BAUDRATE
+#define ETHOCAN_BAUDRATE      (115200)
+#endif
+
+/**
+ * @brief   Stacks for the MAC layer threads
+ */
+static char _netdev_eth_stack[ETHOCAN_MAC_STACKSIZE];

```suggestion
static char _netdev_eth_stack[ARRAY_SIZE(ethocan_params)][ETHOCAN_MAC_STACKSIZE];
```

> +#endif
+
+/**
+ * @brief   Stacks for the MAC layer threads
+ */
+static char _netdev_eth_stack[ETHOCAN_MAC_STACKSIZE];
+
+void auto_init_ethocan(void)
+{
+    LOG_DEBUG("[auto_init_netif] initializing ethocan #0.\n");
+
+    /* setup netdev device */
+    ethocan_params_t p;
+    p.uart = ETHOCAN_UART;
+    p.baudrate = ETHOCAN_BAUDRATE;
+    p.sense_pin = ETHOCAN_SENSE_PIN;

Move these to `ethocan_params.h` like it is done in [`at86rf2xx_params.h`](https://github.com/RIOT-OS/RIOT/blob/master/drivers/at86rf2xx/include/at86rf2xx_params.h#L53).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10710#pullrequestreview-266159146
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190724/a0983efd/attachment.htm>


More information about the notifications mailing list