Skip to content

Instantly share code, notes, and snippets.

View rpoisel's full-sized avatar
👷

Rainer Poisel rpoisel

👷
View GitHub Profile
@rpoisel
rpoisel / bt_replay_nrgkick.py
Last active October 10, 2023 06:51
This snippets sets the amperage of a NRGkick charging cable
from typing import Union
import asyncio
from bleak import BleakClient
from bleak.backends.device import BLEDevice
async def main(address: Union[BLEDevice, str]) -> None:
async with BleakClient(address) as client:
await client.pair()
@rpoisel
rpoisel / DS3502_sample.cpp
Last active June 8, 2023 13:47
Interfacing DS3502 chips without using any Adafruit libraries
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Writes data to an I2C/TWI Peripheral device
// Refer to the "Wire Peripheral Receiver" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
@rpoisel
rpoisel / .envrc
Created May 28, 2023 21:11
pytest and labgrid introduction
export LG_ENV=$(pwd)/inventory.yaml
@rpoisel
rpoisel / realtime_fsm.cpp
Created May 13, 2023 12:43
Realtime FSM implemented in modern C++
#include <csignal>
#include <chrono>
#include <iostream>
#include <optional>
#include <thread>
#include <variant>
template <class Context, class... States> class FSM {
public:
@rpoisel
rpoisel / stack_fsm.cpp
Last active April 17, 2023 08:25
Simple State-Machine similar to HFSM2
#include <csignal>
#include <cstdlib>
#include <ctime>
#include <atomic>
#include <chrono>
#include <iostream>
#include <optional>
#include <thread>
#include <variant>
@rpoisel
rpoisel / .envrc
Last active October 24, 2022 21:09
Sharing Variables between GNU Make and the Bash
file=$(cat env)
for line in $file; do
export "${line}"
done
#include <stddef.h>
#include <stdio.h>
typedef void MyFunc(void);
typedef struct {
int a;
int b;
MyFunc *c;
} MyTransition;
#include <stddef.h>
#include <stdio.h>
typedef struct {
int a;
int b;
} MyLine;
typedef struct {
MyLine const *firstElement;
@rpoisel
rpoisel / pool_manager.cpp
Last active September 23, 2019 11:54
PoolManager for WS workers
#include <algorithm>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <mutex>
#include <thread>
constexpr size_t const NUM_WORKER_THREADS = 3;