Skip to content

Instantly share code, notes, and snippets.

@theterg
theterg / gist:5017229
Created February 22, 2013 22:49
BUG OSGI java reset a BMI port
public void run(Map<Object, Object> services) {
IVonHippelModuleControl vh = (IVonHippelModuleControl) services.get(IVonHippelModuleControl.class.getName());
System.out.println("sysfstest start");
try {
vh.setIOX(0);
vh.setIOX(1);
vh.setIOX(2);
vh.setIOX(3);
} catch (IOException e) { e.printStackTrace(); }
try {
@theterg
theterg / RL78_serial_remote.py
Last active December 29, 2018 12:29
Reverse-engineered pyusb code to read from a renesas RL78G13 promotion board. It uses some random MCU as a debug/programmer tool and a USB->serial device. Windows drivers only. All of the ctrl_transfers were sniffed using wireshark inbetween a windows VM.
import usb.core
import usb.util
import sys
from commands import getstatusoutput
import json
# find our device
dev = usb.core.find(idVendor=0x045b, idProduct=0x0212)
# was it found?
if dev is None:
@theterg
theterg / helloworld.html
Created April 3, 2013 15:23
bugswarm helloworld example, cleaned up and demonstrating arbitrary key value
<html>
<head>
<script type="text/javascript" src="http://cdn.buglabs.net/swarm/swarm-v0.4.0.js"></script>
</head>
<body>
<script>
/* Open this file twice or more and you should be able
to see presence in the developer console of your browser. */
function onPresence(presence) {
console.log('presence -> ' + Date.now() + ':' + JSON.stringify(presence));
@theterg
theterg / SleepPulseFirmware.ino
Last active December 15, 2015 19:49
SleepPulseFirmware.ino
/*
* Sleep Pulse Firmware - firmware code for the Sleep Pulse Device.
* This runs on an Atmel 328P microprocessor, at 5 volts, with a 16 MHz crystal
* Within the arduino IDE, select "Arduino Pro or Pro Mini (5V, 16MHz) w/ATmega328" as the Board
*/
#include <math.h>
#include <EEPROM.h>
// Prototype pin definitions - don't change these!
@theterg
theterg / gist:5496696
Created May 1, 2013 17:18
Bike Air Quality message format
Location is the same as normal, but with some extra data that isn't strictly necessary
{
'feed': {
'latitude': '',
'satellites': 0,
'valid': False,
'longitude': ''
},
'name': 'Location'
@theterg
theterg / gist:5797669
Created June 17, 2013 15:13
Bugcommunity/bugops domains
api.buglabs.net
community.buglabs.net
communityasset0.buglabs.net
communityasset1.buglabs.net
communityasset2.buglabs.net
communityasset3.buglabs.net
cvs.buglabs.net
demo.buglabs.net
demo-ws.buglabs.net
repository.buglabs.net
#include <Servo.h>
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
//16-bit colors, not quite HTML codes even though they look like it... It's a pain:
//http://en.wikipedia.org/wiki/High_color#16-bit_high_color
#define SAMSUNG_BLUE 0x1111
#define SAMSUNG_CYAN 0x0d3c
#define SAMSUNG_GREY 0xbdd7
@theterg
theterg / studio6_linux_conversion.sh
Created July 25, 2013 18:24
A script to convert a Makefile produced by Atmel Studio 6 for arm-none-eabi on a linux host.
#!/bin/sh
PROJECT_NAME=$1
if [ "$PROJECT_NAME" != "" ]; then
# TARGET_DIR=${PROJECT_NAME}/${PROJECT_NAME}/Debug
TARGET_DIR=${PROJECT_NAME}
find ${TARGET_DIR} -iname "*.d" -type f -exec sed -i 's/c:\\.*\\bin\\//g' {} \;
@theterg
theterg / Makefile
Created August 2, 2013 18:11
Bluegiga BTLE test code modified to analyze CRP protocol notification data
CC = gcc
TARGET = test001
MACHINE = $(shell $(CC) -dumpmachine)
# Windows
ifneq (,$(or $(findstring mingw, $(MACHINE)), $(findstring cygwin, $(MACHINE))))
PLATFORM = WIN
LIBS = -lm -lsetupapi
RM = del
@theterg
theterg / pmc.c
Created October 30, 2013 23:23
Atmel Software Framework PMC implementation - NOP WAT
void pmc_enable_waitmode(void)
{
uint32_t i;
/* Flash in Deep Power Down mode */
i = PMC->PMC_FSMR;
i &= ~PMC_FSMR_FLPM_Msk;
i |= ul_flash_in_wait_mode;
PMC->PMC_FSMR = i;