Skip to content

Instantly share code, notes, and snippets.

View mhaberler's full-sized avatar

Michael Haberler mhaberler

View GitHub Profile
@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
@mhaberler
mhaberler / lutn-demo.hal
Last active August 29, 2015 14:16
instantiable HAL component - finalized API
newsig in0 bit
newsig in1 bit
loadrt lutn
newinst lutn or2.0 inputs=2 function=0xe
newinst lutn and2.0 inputs=2 function=0x8
net in0 and2.0.in0 or2.0.in0
net in1 and2.0.in1 or2.0.in1
@mhaberler
mhaberler / mksh.py
Last active August 29, 2015 14:15
example linuxcncrsh - style command interpreter using the Python cmd2 module
# you might have to:
# sudo easy_install cmd2 readline
# or the equivalent debian incantations, whatever they are
from cmd2 import Cmd
import linuxcnc
class MachinekitApp(Cmd):
def __init__(self):
Cmd.__init__(self)
@mhaberler
mhaberler / zreadline.c
Created March 13, 2014 21:35
integrate libreadline into a czmq event loop
// example for integrating readline and
// synchronous signal delivery with czmq/zloop
// Michael Haberler 3/2014
// gcc -g zreadline.o `pkg-config --cflags --libs libczmq` -lreadline -o zreadline
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <stdlib.h>
#include <unistd.h>
@mhaberler
mhaberler / zsigfd.c
Last active January 3, 2016 06:59
example for synchronous signal processing with czmq/zloop using signalfd(2)
// example for synchronous signal processing with czmq/zloop using signalfd(2)
// Michael Haberler 1/2014
#include <czmq.h>
#include <sys/signalfd.h>
int signo;
static int s_handle_signal(zloop_t *loop, zmq_pollitem_t *poller, void *arg)
{