riot and can
play

RIOT and CAN Vincent Dupont OTA keys RIOT Summit September 25-26, - PowerPoint PPT Presentation

RIOT and CAN Vincent Dupont OTA keys RIOT Summit September 25-26, 2017 Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 1 / 34 Who am I? What is OTA keys? Me: Embedded software engineer: 6 years, 3 at OTA keys RIOT: 1.5 year


  1. RIOT and CAN Vincent Dupont OTA keys RIOT Summit September 25-26, 2017 Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 1 / 34

  2. Who am I? What is OTA keys? Me: Embedded software engineer: 6 years, 3 at OTA keys RIOT: 1.5 year Hardware support Device drivers Storage CAN support Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 2 / 34

  3. Who am I? What is OTA keys? Me: Embedded software engineer: 6 years, 3 at OTA keys RIOT: 1.5 year Hardware support Device drivers Storage CAN support OTA keys: Continental subsidiary: car-sharing systems Embedded system, backend, mobile Created 3 years ago, joint-venture between Continental and D’Ieteren (Belgian VW group importer) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 2 / 34

  4. Goal of this presentation 1 CAN bus technology 2 RIOT CAN stack 3 CAN stack usage example Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 3 / 34

  5. Content What is CAN? 1 Physical Layer Link layer ISO-TP CAN in RIOT 2 Use case example: OBD 3 Future 4 Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 4 / 34

  6. What is CAN? Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 5 / 34

  7. Physical Layer: ISO 11898-2 Definition CAN is a multi-master serial bus standard for connecting Electronic Control Units [ECUs] also known as nodes. Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 6 / 34

  8. Physical Layer: ISO 11898-2 Definition CAN is a multi-master serial bus standard for connecting Electronic Control Units [ECUs] also known as nodes. Node 1 Node 2 Node n CAN High CAN Low Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 6 / 34

  9. Physical Layer: ISO 11898-2 Definition CAN is a multi-master serial bus standard for connecting Electronic Control Units [ECUs] also known as nodes. Node 1 Node 2 Node n CAN High CAN Low Recessive bus Dominant bit (0) bus is electrically driven, recessive (1) is not (node is open-drain) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 6 / 34

  10. CAN Layers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 7 / 34

  11. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  12. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) → arbitration phase: Node A 079 0 (SOF) 0 0 0 0 1 1 1 1 0 0 1 Node B 080 0 0 0 0 1 Stops transmitting Node C 700 0 1 Stops transmitting Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  13. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) → arbitration phase: Node A 079 0 (SOF) 0 0 0 0 1 1 1 1 0 0 1 Node B 080 0 0 0 0 1 Stops transmitting Node C 700 0 1 Stops transmitting Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  14. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) → arbitration phase: Node A 079 0 (SOF) 0 0 0 0 1 1 1 1 0 0 1 Node B 080 0 0 0 0 1 Stops transmitting Node C 700 0 1 Stops transmitting Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  15. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) → arbitration phase: Node A 079 0 (SOF) 0 0 0 0 1 1 1 1 0 0 1 Node B 080 0 0 0 0 1 Stops transmitting Node C 700 0 1 Stops transmitting Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  16. Link Layer: ISO 11898-1 8 bytes per frame Error management Frames are addressed, not nodes: CAN IDentifiers IDs are priority (the lower, the more priority) → arbitration phase: Node A 079 0 (SOF) 0 0 0 0 1 1 1 1 0 0 1 Node B 080 0 0 0 0 1 Stops transmitting Node C 700 0 1 Stops transmitting Filters: receive if ( can id & mask ) == filter Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 8 / 34

  17. ISO-TP: ISO 15765-2 Segmentation Up to 4095 bytes Use a pair of CAN IDs “Channel” between 2 nodes Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 9 / 34

  18. ISO-TP: ISO 15765-2 Segmentation Up to 4095 bytes Use a pair of CAN IDs “Channel” between 2 nodes Header (4 bits): Value Definition 0 Single frame (SF) 1 First frame (FF) 2 Consecutive frame (CF) 3 Flow control (FC) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 9 / 34

  19. ISO-TP: ISO 15765-2, Example Node A Node B First frame (length, data) Flow control (block size, stmin) Consecutive frame (index, data) Consecutive frame (...) Consecutive frame (...) Flow control (block size, stmin) Consecutive frame (...) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 10 / 34

  20. Content What is CAN? 1 CAN in RIOT 2 Overall architecture candev Link layer conn can Use case example: OBD 3 Future 4 Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 11 / 34

  21. Architecture conn can conn can isotp isotp CAN link layer raw / router / pkt / dll candev drivers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 12 / 34

  22. Architecture conn can conn can isotp isotp CAN link layer raw / router / pkt / dll candev implement candev drivers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 12 / 34

  23. Architecture conn can conn can isotp conn can user interfaces isotp CAN link layer raw / router / pkt / dll candev implement candev drivers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 12 / 34

  24. Architecture conn can conn can isotp conn can user interfaces isotp CAN stack: isotp, link layer CAN link layer raw / router / pkt / dll candev implement candev drivers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 12 / 34

  25. Architecture conn can conn can isotp conn can user interfaces isotp CAN stack: isotp, link layer CAN link layer 1 thread per layer raw / router / pkt / dll candev implement candev drivers Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 12 / 34

  26. Candev structure typedef struct candev candev_t; typedef void (* candev_event_cb_t )(candev_t *dev , candev_event_t event , void *arg); struct candev { const struct candev_driver *driver; candev_event_cb_t event_callback; void *isr_arg; /* CAN specific */ struct can_bittiming bittiming; enum can_state state; }; Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 13 / 34

  27. Candev driver interface typedef struct candev_driver { int (* init)(candev_t *dev); void (*isr)(candev_t *dev); /* ... */ } candev_driver_t ; Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 14 / 34

  28. Candev driver interface typedef struct candev_driver { int (* init)(candev_t *dev); void (*isr)(candev_t *dev); int (* send)(candev_t *dev , const struct can_frame *frame); int (* abort)(candev_t *dev , const struct can_frame *frame); /* ... */ } candev_driver_t ; Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 14 / 34

  29. Candev driver interface typedef struct candev_driver { int (* init)(candev_t *dev); void (*isr)(candev_t *dev); int (* send)(candev_t *dev , const struct can_frame *frame); int (* abort)(candev_t *dev , const struct can_frame *frame); int (*get)(candev_t *dev , canopt_t opt , void *value , size_t max_len); int (*set)(candev_t *dev , canopt_t opt , void *value , size_t value_len); /* ... */ } candev_driver_t ; Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 14 / 34

  30. Candev driver interface typedef struct candev_driver { int (* init)(candev_t *dev); void (*isr)(candev_t *dev); int (* send)(candev_t *dev , const struct can_frame *frame); int (* abort)(candev_t *dev , const struct can_frame *frame); int (*get)(candev_t *dev , canopt_t opt , void *value , size_t max_len); int (*set)(candev_t *dev , canopt_t opt , void *value , size_t value_len); int (* set_filter)(candev_t *dev , const struct can_filter *filter); int (* remove_filter)(candev_t *dev , const struct can_filter *filter); } candev_driver_t ; Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 14 / 34

  31. Link Layer raw can (dll.c) router pkt (pkt.c): (router.c) wraps gnrc pkt can dll (dll.c) candev (device.c) Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 15 / 34

  32. Link Layer: sending raw can User can dll candev raw can send msg send ok can dll dispatch tx conf msg send Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 16 / 34

  33. Link Layer: receiving, step 1: register filter raw can router User x can dll candev raw can subscribe rx can router register already registered? Register filter Register filter only if needed set filter ok / ko ok / ko Vincent Dupont (OTA keys) RIOT and CAN RIOT Summit 2017 17 / 34

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend