Skip to content

Instantly share code, notes, and snippets.

View Lauszus's full-sized avatar
✈️
In foiling mode

Kristian Sloth Lauszus Lauszus

✈️
In foiling mode
View GitHub Profile
@Lauszus
Lauszus / task.h
Last active November 30, 2023 11:32
FreeRTOS get stack size
/**
* task.h
* <PRE>UBaseType_t uxTaskGetStackSize( TaskHandle_t xTask );</PRE>
*
* Returns the stack size associated with xTask. That is, the stack
* size (in words, so on a 32 bit machine a value of 1 means 4 bytes) of the task.
*
* @param xTask Handle of the task associated with the stack to be checked.
* Set xTask to NULL to check the stack of the calling task.
*
@Lauszus
Lauszus / GPS.py
Created February 21, 2019 10:31
GPS NMEA string generator
#!/usr/bin/env python
import numpy as np
def main():
def ubx_checksum(data):
ck_a = 0
ck_b = 0
for byte in data:
@Lauszus
Lauszus / crc.py
Last active December 12, 2024 21:06
Generic CRC-8, CRC-16 and CRC-32 calculations in Python
#!/usr/bin/env python
# Inspired by: https://www.youtube.com/watch?v=izG7qT0EpBw
# The CRC values are verified using: https://crccalc.com/
def reflect_data(x, width):
# See: https://stackoverflow.com/a/20918545
if width == 8:
x = ((x & 0x55) << 1) | ((x & 0xAA) >> 1)
x = ((x & 0x33) << 2) | ((x & 0xCC) >> 2)
x = ((x & 0x0F) << 4) | ((x & 0xF0) >> 4)
@Lauszus
Lauszus / gh-dl-release
Created June 6, 2019 18:53 — forked from maxim/gh-dl-release
Download assets from private Github releases
#!/bin/bash -e
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@Lauszus
Lauszus / hass_install_notes.md
Last active December 9, 2019 22:12
Home Assistant Docker installation notes on a Raspberry Pi 3

Install some required packages first:

sudo apt-get update
sudo apt-get install -y \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common
@Lauszus
Lauszus / 80-can.network
Last active June 7, 2025 01:25
Ubuntu 20.04 auto configure CAN bus interfaces using systemd
[Match]
Name=can*
[CAN]
BitRate=250000
RestartSec=100ms
# Put this file in: "/etc/systemd/network/" and then run "sudo systemctl enable systemd-networkd" to enable systemd-networkd
# Now start systemd-networkd: "sudo systemctl start systemd-networkd"
# Credit: https://github.com/linux-can/can-utils/issues/68#issuecomment-584505426
@Lauszus
Lauszus / os-release-bionic
Last active October 31, 2023 12:52
Nvidia SDKManager on Ubuntu 20.04
# Put in "/usr/lib/os-release-bionic"
NAME="Ubuntu"
VERSION="18.04 (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04"
VERSION_ID="18.04"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
@Lauszus
Lauszus / main.py
Created October 1, 2020 13:50
Siglent SDS2000X plus hack
import hashlib
SCOPEID = '0000000000000000'
Model = 'SDS2000X+'
# Note that 'AWG' should be used for the 'FG' option
# If you have the 100 MHz model, then first upgrade it to 200 MHz, then 350 MHz and finally 500 MHz
bwopt = ('25M', '40M', '50M', '60M', '70M', '100M', '150M', '200M', '250M', '300M', '350M', '500M', '750M', '1000M', 'MAX', 'AWG', 'WIFI', 'MSO', 'FLX', 'CFD', 'I2S', '1553', 'PWA')
hashkey = '5zao9lyua01pp7hjzm3orcq90mds63z6zi5kv7vmv3ih981vlwn06txnjdtas3u2wa8msx61i12ueh14t7kqwsfskg032nhyuy1d9vv2wm925rd18kih9xhkyilobbgy'
@Lauszus
Lauszus / mcp2515-spi0-4cs-overlay.dts
Last active February 16, 2024 11:50
Raspberry Pi device tree overlay for creating up to four CAN-Bus interfaces on spi0 using four MCP2515's
/*
* Device tree overlay for mcp251x on any spi interface by Kristian Sloth Lauszus.
* Should be used with the "spi0-4cs" overlay.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
@Lauszus
Lauszus / max98357a-no-din-overlay.dts
Created February 23, 2021 16:24
Maxim MAX98357A audio DAC without using the PCM_DIN pin
// Overlay for Maxim MAX98357A audio DAC without using the PCM_DIN pin
// dtparams:
// sdmode-pin - Specify GPIO pin to which SD_MODE is connected (default 20).
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";