Skip to content

Instantly share code, notes, and snippets.

View mhaberler's full-sized avatar

Michael Haberler mhaberler

View GitHub Profile
@mhaberler
mhaberler / dsdtech.py
Created May 21, 2022 09:26
drive DSD Tech BLE Relay via Python & bleak
"""
Connect by BLEDevice
"""
import asyncio
import platform
import sys
from bleak import BleakClient, BleakScanner
from bleak.exc import BleakError
# Intended to convert a typical radar lla and az el to a cesium quaternion orientation for CZML
# Uses numpy, transformations.py (http://www.lfd.uci.edu/~gohlke/code/transformations.py.html),
# and ecef.py (https://code.google.com/p/pysatel/source/browse/trunk/coord.py?r=22)
def azEl2Quaternion(lat, lon, alt, az, el):
rotZ = rotation_matrix(math.radians(180+az), [0,0,1])
rotY = rotation_matrix(math.radians(-(90+el)), [0,1,0])
rotM = np.dot(rotZ, rotY)
origin = geodetic2ecef(lat, lon, alt)
origin = np.multiply(origin, 1000)
@mhaberler
mhaberler / README.md
Last active June 27, 2016 19:27
running jekyll-asciidoctor with LiveReload on change

The machinekit.io website is formatted with the docker-jekyll-asciidoctor docker image.

to run this locally "at home":

  • install docker - see https://docs.docker.com/engine/installation/linux/debian/
  • pull the image from dockerhub: docker pull haberlerm/docker-jekyll-asciidoctor
  • review and run the serve.sh script in the toplevel directory of your website
  • review the values in config_preview.yml which were generated by the first run
  • run serve.sh again, let it run to completion for the initial format of the whole site which can take 10-15mins
  • stop serve.sh with ^C and run it again, it will start with --incremental --skip-initial-build for quick startup since the _site directory already exists
@mhaberler
mhaberler / README-machinekit-terasic-de0.md
Last active March 16, 2020 10:28
Installing the Machinekit Altera CycloneV test image

Contents

This SD image is a debian jessie console image with:

  • a 4.1.22-ltsi-rt kernel with RT-PREEMPT patches applied
  • tested on Terasic DE0-Nano-SoC Kit, other SoCKit platforms should work with appropriate dtb
  • machinekit RIP-build under /home/machinekit/machinekit, all build artefacts are in place (no need to run make)
  • machinekit packages are NOT installed and you do not have to!
  • all machinekit build- and runtime required packages ARE installed.
  • /home/machinekit/.bashrc already set up to run machinekit from the RIP build directory.
  • one known-to-work configuration with hostmot2/onboard FPGA support is: machinekit/configs/hm2-soc-stepper/5i25-socfpga.ini
@mhaberler
mhaberler / blinkenleds.hal
Last active April 24, 2016 06:17
Blinkenleds with hm2_soc driver
loadrt hostmot2
loadrt hm2_soc config="firmware=socfpga/soc_system.rbf num_encoders=2 num_pwmgens=2 num_stepgens=2"
newthread servo-thread 1000000 fp
newthread slow 1000000000 fp # 1sec
# task1: blink the leds CR01 and CR02
newinst not osci
newinst not inverter
@mhaberler
mhaberler / ros-bb-jessie.sh
Created January 5, 2016 20:52
installing ROS indigo ROS-comm on beaglebone jessie
# derived from http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Indigo%20on%20Raspberry%20Pi
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu jessie main" > /etc/apt/sources.list.d/ros-latest.list'
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
@mhaberler
mhaberler / ptpd
Last active June 13, 2023 12:29
ptpd (Precision Time Protocol) config files for debian
# /etc/default/ptpd
# Set to "yes" to actually start ptpd automatically
START_DAEMON=yes
# Add command line options for ptpd
PTPD_OPTS="-c /etc/ptpd.conf"
@mhaberler
mhaberler / Makefile
Created July 30, 2015 13:11
see what gcc and c++ generate for atomic builtins (NOT std::atomic)
all: atomic-c++.s atomic-c.s atomic-c++ atomic-c
clean:
rm -f atomic-c++.s atomic-c.s atomic-c++ atomic-c
atomic-c++.s: atomic.c
gcc -x c++ -std=c++11 -Wa,-adhln -g $^ > $@
atomic-c++: atomic.c
gcc -x c++ -std=c++11 -g $^ -o $@
@mhaberler
mhaberler / 90-slcan.rules
Created May 3, 2015 13:29
making USBtin work with wheezy boot-time
# add this file to /etc/udev/rules.d:
# 04d8:000a USBtin
KERNEL=="ttyACM*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="000a",SYMLINK+="USBtin%n" ,RUN+="/usr/local/bin/slcan.sh /dev/%k can%n"
@mhaberler
mhaberler / README.vcan
Last active August 29, 2015 14:20
setting up vcan (virtual can interface - loopback) in wheezy
# in /etc/modules add
vcan
so the vcan module is loaded at boot
# in /etc/rc.local, add
ip link add dev vcan0 type vcan
ip link set up vcan0