Skip to content

Instantly share code, notes, and snippets.

@rxseger
rxseger / gptray.py
Last active August 31, 2016 05:29
CD/DVD ROM tray open/closed switch GPIO script for Raspberry Pi
#!/usr/bin/python
# turn on yellow LED when CD/DVD tray fully open, blue LED when fully closed
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
OPSW = 22 # G25
@rxseger
rxseger / parallel-eprom-dump.py
Last active August 29, 2016 03:53
parallel memory dumping using Raspberry Pi GPIO, for AT27C080 8Mbit CMOS EPROM
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
# Data and address pins
# MSB first
@rxseger
rxseger / gist:251bffd789a6414a6b1f3c9e3b1ccf64
Last active August 28, 2016 22:14
Samsung DVD-M101 DVD Player MIC4 2K EEPROM I2C dump using Bus Pirate
00000000 ?? 88 56 82 8c 6f 58 50 80 50 82 22 5d a0 b0 c2 |..V..oXP.P."]...|
00000010 20 86 c0 9a 82 94 79 6a 50 80 70 71 36 54 a0 b0 | .....yjP.pq6T..|
00000020 c2 20 82 92 58 88 96 6f 00 a0 80 70 81 02 4b a0 |. ..X..o...p..K.|
00000030 b0 c5 20 60 89 cb 80 70 60 00 a0 80 80 82 03 03 |.. `...p`.......|
00000040 a0 a8 cd 2c 84 f6 0c 20 61 c8 0c 20 61 c8 08 20 |...,... a.. a.. |
00000050 60 08 40 f4 40 43 40 f4 40 43 40 f4 42 41 ff ff |`.@.@C@.@[email protected]..|
00000060 00 11 00 7b 7b 7b 00 ff ff ff ff 7b 7b 7b 7b 00 |...{{{.....{{{{.|
00000070 ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 7b |...............{|
00000080 00 02 00 02 00 02 00 01 04 00 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 |................|
@rxseger
rxseger / write-eeprom16.py
Created August 26, 2016 06:55
write 16-bit EEPROMs over I2C
#!/usr/bin/python
# write 16-bit EEPROMs over I2C
import sys
import smbus
import time
bus = smbus.SMBus(1)
if len(sys.argv) < 2:
sys.stderr.write("usage: %s device-address\n" % (sys.argv[0],))
@rxseger
rxseger / read-eeprom16.py
Created August 26, 2016 06:52
read 16-bit EEPROMs over I2C
#!/usr/bin/python
# read 16-bit EEPROMs over I2C. tested with 24FC512 and 24LC515
import sys
import smbus
bus = smbus.SMBus(1) # /dev/i2c-1
if len(sys.argv) < 3:
sys.stderr.write("usage: %s device_address size > filename\n" % (sys.argv[0],))
raise SystemExit
@rxseger
rxseger / gpint
Created August 21, 2016 19:04
/etc/init.d/gpint daemon script for gpint.py https://gist.github.com/rxseger/cb10cb02b27f32b7a0003d03afb35db7
#!/bin/sh
### BEGIN INIT INFO
# Provides: gpint
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Interrupt-based GPIO LED/pushbutton daemon
# Description: Listens for button events and lights up LEDs
### END INIT INFO
@rxseger
rxseger / gpint.py
Created August 21, 2016 19:03
interrupt-driven GPIO example using LEDs and pushbuttons for Raspberry Pi 3
#!/usr/bin/python
# interrupt-based GPIO example using LEDs and pushbuttons
import RPi.GPIO as GPIO
import time
import threading
GPIO.setmode(GPIO.BOARD)
@rxseger
rxseger / crypt.c
Created August 14, 2016 06:02
crypt(3) command-line wrapper, compile with: cc crypt.c -o crypt -lcrypt
#include <stdio.h>
#include <crypt.h>
int main(int argc, char **argv) {
if (argc < 3) {
fprintf(stderr, "usage: %s key salt\n", argv[0]);
return -1;
}
char *result = crypt(argv[1], argv[2]);
if (!result)
@rxseger
rxseger / flightled.py
Last active July 13, 2016 02:36
flightled.py - light up LEDs using GPIO in response to dump1090 flights
#!/usr/bin/python
# Light up LEDs using GPIO in response to dump1090 flights
### MOVED TO https://github.com/rxseger/flightled
import socket
import select
import time
import datetime
import os
import RPi.GPIO as GPIO
@rxseger
rxseger / flightled
Last active July 13, 2016 02:36
/etc/init.d/flightled startup script for flightled.py
#!/bin/sh
#### MOVED TO https://github.com/rxseger/flightled
### BEGIN INIT INFO
# Provides: flightled
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Light up LEDs when a watched flight is observed