Skip to content

Instantly share code, notes, and snippets.

@timmaxw
timmaxw / instructions.md
Created May 12, 2024 03:43
How to Emulate DPC-11 programmer using clone FTDI adapter and Arduino Nano

How to Emulate DPC-11 programmer using clone FTDI adapter and Arduino Nano

Suppose you want to program a Hitec D-series digital servo, but you don't have Hitec's DPC-11 dongle. This guide describes how to use an FTDI serial adapter and an Arduino in place of Hitec's DPC-11 dongle, so you can use Hitec's GUI without having the physical DPC-11 dongle.

Motivation: This lets you reprogram the endpoints of your servo to be whatever you want. The range of motion can be increased to 180 degrees. Fail safe positions can be set, overload protection settings, dead band, speed, and more..

Let's get started.

Flash your arduino with the following code (just about any arduino will work):

@timmaxw
timmaxw / lagcurse.py
Created January 9, 2023 20:30
lagcurse.py: randomly introduce lag into a running process
#!/usr/bin/env python3
"""
lagcurse.py uses the Linux ptrace() API to pause/unpause threads of the given
process at random intervals. This can be helpful for fuzzing race conditions or
simulating CPU contention. See "lagcurse.py -h" for usage information.
"""
import argparse
import ctypes
@timmaxw
timmaxw / Valgrind output
Created June 12, 2012 23:24
Possible bug in Clang 3.0-6ubuntu
==6649== Memcheck, a memory error detector
==6649== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==6649== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==6649== Command: ./test
==6649==
==6649== Invalid read of size 8
==6649== at 0x4EC9063: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16)
==6649== by 0x400B6E: main (in /home/ssd0/tim/scratch/clang-pointer-to-method/test)
==6649== Address 0x5a04040 is 0 bytes inside a block of size 38 free'd
==6649== at 0x4C2A4BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
@timmaxw
timmaxw / gist:1597379
Created January 11, 2012 23:11
C++ puzzle 2
#include <iostream>
using namespace std;
template<class T>
struct B {
struct X {
T t;
};
};
@timmaxw
timmaxw / Balls.hs
Created November 24, 2011 19:52
Haskell solution to "12 balls and scale" problem
import Control.Exception (assert)
import Control.Monad.Writer
import Data.List (intercalate, nub)
import Prelude hiding (Left, Right)
slice :: (Int, Int) -> [a] -> [a]
slice (l, r) x = take (r - l) $ drop l $ x
data Ball = Ball Int deriving (Eq, Show)
data Bias = Heavier | Lighter deriving (Eq, Show)
@timmaxw
timmaxw / gist:1207668
Created September 10, 2011 00:11
C++ puzzle
#include <iostream>
/* Under GCC 4.4.1, VERSION_1 fails but VERSION_2 and VERSION_3 work. */
#ifdef VERSION_1
void show(std::string s) {
std::cout << s << std::endl;
}