Slide 1

Slide 1 text

CAN bus emulation with FreeRTOS and Qt Andrei Mukamolau, Dmitriy Stupak

Slide 2

Slide 2 text

Contents 1. Why 2. Prerequisites 3. FreeRTOS app 4. Qt app 5. Demo

Slide 3

Slide 3 text

Who we are ● Automotive software development company ● Develop and design apps ● HMI ● Android Automotive ● Connected cars

Slide 4

Slide 4 text

Problem ● App testing requires real data from the vehicle ● It can be only obtained from the vehicle ● We don’t often have needed vehicle available ● Testing becomes expensive

Slide 5

Slide 5 text

Solution ● Cheap CAN bus stand for development ● Close to real life technologies ● Test apps without vehicle

Slide 6

Slide 6 text

Hardware used in cars ● Sensors ● ECUs ● Instrument cluster ● Infotainment ● CAN bus

Slide 7

Slide 7 text

CAN bus ● Controlled Area Network ● 2-way short range communication ● Used in automotive and industrial apps ● Simple at first glance ● Fast ● Robust

Slide 8

Slide 8 text

Software used in cars ● Embedded soft for sensors ● RTOS for ECUs ● Embedded Linux for infotainment and instrument cluster ● Android Automotive for infotainment

Slide 9

Slide 9 text

Software used in cars ● Embedded soft for sensors ● RTOS for ECUs ● Embedded Linux for infotainment and instrument cluster ● Android Automotive for infotainment

Slide 10

Slide 10 text

RTOS ● Real Time Operating System ● Scheduler runs tasks for a fixed amount of time ● May not have all the features of standard OSes ● Critical for safety-related systems

Slide 11

Slide 11 text

RTOSes ● QNX ● VxWorks ● FreeRTOS

Slide 12

Slide 12 text

Software used in cars ● Embedded soft for sensors ● RTOS for ECUs ● Embedded Linux for infotainment and instrument cluster ● Android Automotive for infotainment

Slide 13

Slide 13 text

Embedded Linux ● Regular Linux kernel, tuned for specific hardware ● UI can be done in any way ● Most popular is Qt

Slide 14

Slide 14 text

Tech stack ● Arduino Uno with FreeRTOS app ● Raspberry Pi with Qt app

Slide 15

Slide 15 text

FreeRTOS app

Slide 16

Slide 16 text

Hardware ● Arduino Uno ● CAN bus shield ● Buttons ● Wires ● 10 kOhm resistor

Slide 17

Slide 17 text

Software ● PlatformIO ● C++ (Arduino) ● FreeRTOS

Slide 18

Slide 18 text

Advantages ● Arduino is cheap ● Highly configurable ● Can be extended and ported easily ● FreeRTOS is flexible enough ● Can be used backwards

Slide 19

Slide 19 text

Problems ● Arduino Uno is not so powerful ● FreeRTOS eats up memory if you’re not careful ● Jitter

Slide 20

Slide 20 text

Qt app

Slide 21

Slide 21 text

What’s Qt ● Cross-platform framework ● Written in C++ ● Signals and slots ● Double licensing ● Its own IDE - Qt Creator

Slide 22

Slide 22 text

Technologies/Tools

Slide 23

Slide 23 text

Qt Creator

Slide 24

Slide 24 text

Qt Creator - design editor

Slide 25

Slide 25 text

Connect can or vcan ● Guide ● Connect physical CAN HAT ● Install the necessary modules ● Set up it with commands ● Install can-utils ● Turn on the interface ● Send frames with can-utils The same for vcan but without physical part

Slide 26

Slide 26 text

Cross-platform application Windows 10 Raspberry OS macOS

Slide 27

Slide 27 text

Hiccups ● C++ errors are obscure ● CAN loopback didn’t work ● Qt libs on Raspberry are not available by default ● Qt versions mismatch Win/Mac Qt 6.4.3 Raspberry OS 5.15.5

Slide 28

Slide 28 text

Demo app workflow ● Click on the button on Arduino ● Build CAN signal and send to Raspberry Pi via CAN wires ● Receive CAN frame and process it ● Visualize it in Qt application

Slide 29

Slide 29 text

Demo

Slide 30

Slide 30 text

Q&A

Slide 31

Slide 31 text

Thanks!