Skip to content

Instantly share code, notes, and snippets.

Fractal Components

A code generation platform for distributed embedded systems.

Most of the code in an embedded system deals with IO, both with sensors and actuators, as well as communicating with a PC, phone, or server. Typically the domain logic implementing the unique behavior that the developer actually cares about is a small portion of the code, but ends up intertwined with all the IO, making it hard to introspect and port between platforms.

Fractal is about breaking the IO into reusable chunks, called components, with structured interfaces defined by state machines, and automatically generating code for them to communicate with each other, whether they're on the same physical hardware or across a network. By simplifying IO, developers can focus on the domain logic unique to their application.

Code in multiple languages can be mixed and matched, so developers can pick the right language for each task -- Rust and C for size and speed, JS or Lua for familiarity, ease of prototyping, and existing netw

@kevinmehall
kevinmehall / Dockerfile
Created November 3, 2014 19:20
connect cross-compile in docker
FROM fedora:20
RUN yum install -y git cmake make libtool \
mingw32 mingw32-binutils mingw32-runtime mingw32-gcc-c++ \
mingw32-boost mingw32-boost-static.noarch \
&& yum clean all
@kevinmehall
kevinmehall / output
Created December 22, 2014 04:27
LLVM immediate offset missed optimization for ARM thumb register access
Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
00008000 <main>:
8000: 4802 ldr r0, [pc, #8] ; (800c <main+0xc>)
8002: 2101 movs r1, #1
8004: 6001 str r1, [r0, #0]
8006: 4802 ldr r0, [pc, #8] ; (8010 <main+0x10>)
8008: 6001 str r1, [r0, #0]
800a: 4770 bx lr
800c: 10001004 .word 0x10001004
8010: 10001008 .word 0x10001008
@kevinmehall
kevinmehall / verify.rs
Created July 18, 2015 22:59
Check Saleae CSV dumps from Tessel 2 bridge for timing margin
use std::io;
use std::io::prelude::*;
use std::fs;
use std::env;
use std::cmp::Ordering;
fn main() {
let args: Vec<String> = env::args().collect();
let file = io::BufReader::new(fs::File::open(&args[1]).unwrap());
@kevinmehall
kevinmehall / testing.md
Last active August 29, 2015 14:25
Tessel wifi testing

Install: on both Tessels

opkg update
opkg install tcpdump
wget https://kevinmehall.net/tmp/packetspammer -O /usr/bin/packetspammer
chmod +x /usr/bin/packetspammer

Setup: on both Tessels

import os
def randid():
r = bytearray(os.urandom(16))
s = ""
for i in range(24):
idx, pos = (i*5)/8, (i*5)%8
val = ((r[idx] >> pos) | (r[idx+1] << (8-pos))) & ((1<<5)-1)
<!doctype html>
<html><head>
<script>
function init(){
var canvas = document.getElementById('canvas')
var width = canvas.width = window.innerWidth-10
var height = canvas.height = window.innerHeight-10
var c = canvas.getContext('2d');
# Decode UAVCAN transfers from a CAN dump CSV exported from Saleae Logic
import argparse
import csv
import uavcan
from uavcan.transport import TransferManager, Frame, Transfer
def parsecsv(f):
manager = TransferManager()
reader = csv.reader(f, delimiter=',')
@kevinmehall
kevinmehall / gist:1224653
Created September 18, 2011 02:47
AlJazeera English Live with rtmpdump and mplayer (17 September 2011)
rtmpdump -v -r rtmp://livestfslivefs.fplive.net/aljazeeraflashlive-live -y "aljazeera_eng_high?videoId=883816736001&lineUpId=&pubId=6650033.03001&playerId=751182905001&affiliateId=" -W "http://admin.brightcove.com/viewer/us20110916.1045/BrightcoveBootloader.swf" -p "http://english.aljazeera.net/watch_now/" -a "aljazeeraflashlive-live?videoId=883816736001&lineUpId=&pubId=6650033.03001&playerId=751182905001&affiliateId=" | mplayer -
@kevinmehall
kevinmehall / async_replace.coffee
Created September 14, 2012 22:27
Async find/replace in CoffeeScript
# Replace parts of `string` matching regex `pattern` with the callback value of an
# async function `fn`, which receives the regex match object and callback. Calls `cb` with
# final string when complete.
asyncReplace = (string, pattern, fn, cb)->
console.assert(pattern.global, "asyncReplace pattern must be global (g flag)")
outChunks = []
lastIndex = 0
pendingCb = 0