Difference between revisions of "Datalogger"

From 'Engineers of Innovation Wiki'
Jump to navigation Jump to search
(Added datalog format that the datalogger generates)
(added GNSS can messages)
 
(One intermediate revision by the same user not shown)
Line 228: Line 228:


Daemons and services for gui and other scripts?
Daemons and services for gui and other scripts?
== CAN bus ID Overview ==
<syntaxhighlight lang="text">
0x100 EoI Battery start
0x10F EoI Battery end
0x200 EoI GNNS info, u8 fix (bool); u8 sats; u8 sats used
0x201 EoI GNNS f32 speed, kmh; f32 direction, degrees
0x202 EoI GNNS f64 Latitude, degrees
0x203 EoI GNNS f64 Longitude, degrees
0x204 EoI GNNS date time, u16 year, u8 month, u8 day, u8 hour, u8 minute, u8 second
0x302 MG Battery
0x402 MG Battery
0x482 MG Battery cell voltage
0x700 MPPT start
0x77F MPPT end
0x0900 THROTTLE To VESC
0x1337 THROTTLE Status
0x0909 VESC Status message 1
0x0E09 VESC Status message 2
0x0F09 VESC Status message 3
0x1009 VESC Status message 4
0x1B09 VESC Status message 5
</syntaxhighlight>

Latest revision as of 21:46, 3 May 2025

The datalogger is a PCB that stores the CAN-bus data and shows the data on-screen and sends this data to one of the EoI-servers.

The datalogger is quite complex since it is an embedded Linux platform as well as a screen. The embedded platform makes use of a root file system. Compiling of this file system and any modifications are discussed below.

The screen makes use of cross-compiling QT and is on itself quite the big project for compiling and modifying the generated GUI for the screen. Therefore one can read more about this topic at QT Creator Setup.

Datalogs format

As of October '22 the datalogger GUI is accessing the CAN-bus data and creating the logfiles and writing them onto its filesystem. The delimiter of the logfile format is a space, this is done to support the http://www.gnuplot.info/ software. This should probably be delimited with a comma or something else.

A snipped of a logfile is given below:

2022-08-27-09-46-55 807280 47.8 -25.4 3.09 28.5 96 3.99 32.6411 -16.9088 15.2 261 
2022-08-27-09-46-56 807530 47.8 -24.9 3.09 28 96 3.99 32.6411 -16.9088 15.2 261 
2022-08-27-09-46-56 807680 47.8 -24.9 3.45 28.3 96 3.99 32.6411 -16.9088 15.2 261 
2022-08-27-09-46-57 807910 47.8 -25.9 3.29 29.2 96 3.99 32.6411 -16.9089 15.2 261 
2022-08-27-09-46-57 808090 47.8 -26.2 2.98 29.2 96 3.99 32.6411 -16.9089 15.2 261 
2022-08-27-09-46-58 808340 47.8 -25.9 3.4 29.4 96 3.99 32.6411 -16.9089 15.2 260 
2022-08-27-09-46-58 808560 47.8 -24.9 2.98 27.9 96 3.99 32.6411 -16.9089 15.2 260 
2022-08-27-09-46-59 808740 47.8 -26 3.02 29 96 3.99 32.6411 -16.909 15.2 261
Date and Time Time since start Battery voltage [V] Battery current netto [A] Battery current in [A] Battery current out [A] SoC [%] Highest cell voltage [V] GPS latitude GPS longitude GPS speed [km/h] GPS track
2022-08-27-09-46-55 807280 47.8 -25.4 3.09 28.5 96 3.99 32.6411 -16.9088 15.2 261

Rootfs

The datalogger uses a Debian 10 root file system (rootfs), this page walks you through the steps of setting this up and making modifications.

This process has been automated, this is described in the datalogger rootfs repository https://git.engineersofinnovation.nl/datalogger/rootfs

If you'd like do all the steps manually by all means, please continue reading.

Creating a Debian filesystem

To  create  a  filesystem  we  use debootstrap. This guide has been tested on Ubuntu 18.04 and Debian 10 Host machines.

1. Install the required dependencies

sudo apt update && sudo apt install debootstrap qemu-user-static binfmt-support

2. Create a new directory 'debian-fs' and enter it

mkdir ~/Documents/Datalogger/rootfs

cd ~/Documents/Datalogger/rootfs

3. run the first stage bootstrap

debootstrap --no-check-gpg --arch=armhf --foreign --include apt,kmod,lsof,ssh,wget,dialog buster rootfs http://deb.debian.org/debian/

4. set up emulation by copying the qemu executable

sudo cp ./qemu-arm-static rootfs/usr/bin

5. run the second stage debootstrap

sudo chroot rootfs /debootstrap/debootstrap --second-stage

6. Configure the rootfs for your board, run the following script

#!/bin/sh

# Modification from acmesystems acqua.sh, please visit their website for great documentation! (acmesystems.it)

# Directory contains the target rootfs

TARGET_ROOTFS_DIR="rootfs"

# Board hostname

filename=$TARGET_ROOTFS_DIR/etc/hostname

echo eoi-datalogger > $filename

# bashrc user/hostname color (optional)

filename=$TARGET_ROOTFS_DIR/root/.bashrc

echo >> $filename

echo "PS1='\${debian_chroot:+(\$debian_chroot)}\[\033[01;96m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\\$ '" >> $filename

# Default name servers

filename=$TARGET_ROOTFS_DIR/etc/resolv.conf

echo nameserver 8.8.8.8 > $filename

echo nameserver 8.8.4.4 >> $filename

# Default network interfaces

filename=$TARGET_ROOTFS_DIR/etc/network/interfaces

echo >> $filename

#echo auto eth0 >> $filename

echo allow-hotplug eth0 >> $filename

echo iface eth0 inet dhcp >> $filename

echo hwaddress ether 00:04:25:12:34:56 >> $filename    #eth0 MAC address

echo >> $filename

echo auto wlan0 >> $filename

echo iface wlan0 inet dhcp >> $filename

echo wireless-essid any >> $filename

echo pre-up wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B >> $filename

echo post-down killall -q wpa_supplicant >> $filename

# configure Wi-Fi AP

filename=$TARGET_ROOTFS_DIR/etc/wpa_supplicant.conf

touch $filename

echo ctrl_interface=/var/run/wpa_supplicant > $filename

echo ap_scan=1 >> $filename

echo >> $filename

echo network={ >> $filename

echo 'ssid="testnaam"' >> $filename

echo 'psk="testtest"' >> $filename

echo } >> $filename

# Set the the debug port

filename=$TARGET_ROOTFS_DIR/etc/inittab

echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> $filename

# Set rules to change wlan dongles

filename=$TARGET_ROOTFS_DIR/etc/udev/rules.d/70-persistent-net.rules

echo SUBSYSTEM=='"net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"' > $filename

# microSD partitions mounting

filename=$TARGET_ROOTFS_DIR/etc/fstab

echo /dev/mmcblk0p1 /boot vfat noatime 0 1 > $filename

echo /dev/mmcblk0p2 / ext4 noatime 0 1 >> $filename

echo proc /proc proc defaults 0 0 >> $filename

# Add the standard Debian non-free repositories useful to load

# closed source firmware (i.e. WiFi dongle firmware)

filename=$TARGET_ROOTFS_DIR/etc/apt/sources.list

echo deb http://deb.debian.org/debian/ buster main contrib non-free > $filename

echo deb-src http://deb.debian.org/debian/ buster main contrib non-free >> $filename

7. Install required packages

```

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt update

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt install -y net-tools udev iputils-ping ifupdown isc-dhcp-client ca-certificates wpasupplicant firmware-ralink wvdial iw resolvconf libssl-dev ppp autossh

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt install -y locales adduser nano usbutils can-utils i2c-tools git fonts-dejavu gpsd gpsd-clients libqgpsmm-dev libqgpsmm23 minicom picocom python3 python3-pip python3-numpy libsocketcan-dev psmisc moreutils

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt install -y libgl1-mesa-dev libgl1-mesa-dri libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libegl1-mesa libegl1-mesa-dev libgles2-mesa-dev mesa-common-dev mesa-utils libgbm-dev libgbm1 libbz2-dev libdrm-dev libgles2-mesa

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt install -y qt5-default qtdeclarative5-* qml-module-qtquick* qml-module-qtquick2 qtquickcontrols5-* qtserialbus5-* qttools5-* qtbase5-* libqt5svg5-* libqtwebkit-* qtmultimedia5-* qmlscene qml gstreamer1.0-omx libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt build-dep qt4-x11 -y

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs apt build-dep libqt5gui5 -y

8. set a root password

sudo chroot rootfs passwd

9. remove the qemu binary

sudo rm rootfs/usr/bin/qemu-arm-static

10. download and apply the patchfiles

wget https://git.engineersofinnovation.nl/datalogger/rootfs/-/raw/master/patches/ssh_patch.patch

wget https://git.engineersofinnovation.nl/datalogger/rootfs/-/raw/master/patches/ssh_patch_client.patch

wget https://git.engineersofinnovation.nl/datalogger/rootfs/-/raw/master/patches/gpsd_patch.patch

wget https://git.engineersofinnovation.nl/datalogger/rootfs/-/raw/master/patches/4g_patch.patch

sudo patch -p1 < ./patches/ssh_patch.patch

sudo patch -p1 < ./patches/ssh_patch_client.patch

sudo patch -p1 < ./patches/gpsd_patch.patch

sudo patch -p1 < ./patches/4g_patch.patch

11. Other stuff

PPP setup?

https://github.com/sixfab/Sixfab_PPP_Installer

Daemons and services for gui and other scripts?

CAN bus ID Overview

0x100 EoI Battery start
0x10F EoI Battery end

0x200 EoI GNNS info, u8 fix (bool); u8 sats; u8 sats used 
0x201 EoI GNNS f32 speed, kmh; f32 direction, degrees
0x202 EoI GNNS f64 Latitude, degrees
0x203 EoI GNNS f64 Longitude, degrees
0x204 EoI GNNS date time, u16 year, u8 month, u8 day, u8 hour, u8 minute, u8 second

0x302 MG Battery 
0x402 MG Battery
0x482 MG Battery cell voltage

0x700 MPPT start
0x77F MPPT end

0x0900 THROTTLE To VESC
0x1337 THROTTLE Status

0x0909 VESC Status message 1
0x0E09 VESC Status message 2
0x0F09 VESC Status message 3
0x1009 VESC Status message 4
0x1B09 VESC Status message 5