Skip to content

Instantly share code, notes, and snippets.

View dominicgs's full-sized avatar

Dominic Spill dominicgs

View GitHub Profile
@dominicgs
dominicgs / wcid_test.py
Last active July 18, 2017 21:47
A simple script to test the WCIDs that I've been adding to our USB projects (https://github.com/pbatard/libwdi/wiki/WCID-Devices)
#!/usr/bin/env python3
from __future__ import print_function
import usb
import argparse
import sys
from usb.control import get_descriptor
def print_feature_descriptor(feat_desc):
@dominicgs
dominicgs / OSHPark_colour_mod.py
Created June 29, 2017 23:41
Remap OSH Park PCB preview images to other soldermask and silkscreen colours
#!/usr/bin/env python3
import argparse
import struct
from PIL import Image
if __name__ == "__main__":
colour_map = {
(193, 177, 203) : (193, 177, 203),# silkscreen
(197, 183, 208) : (197, 183, 208), # silkscreen + copper
#/usr/bin/env python3
import csv
class Pin(object):
def __init__(self, name, number):
self.name = name
if self.name.startswith('P'):
x = self.name.split('_')
self.port = x[0].strip('P')
Multiplexed digital pins
P0_0 L3 K3 G2 32 [2] N; I/O GPIO0[0] — General purpose digital input/output pin.
PU I/O SSP1_MISO — Master In Slave Out for SSP1.
I ENET_RXD1 — Ethernet receive data 1 (RMII/MII interface).
I/O SGPIO0 — General purpose digital input/output pin.
- R — Function reserved.
- R — Function reserved.
I/O I2S0_TX_WS — Transmit Word Select. It is driven by the master and received by the slave. Corresponds to the signal WS in the I 2 S-bus specification.
/*
* Copyright 2016 Dominic Spill <dominicgs@gmail.com>
*
* This file is part of HackRF.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
@dominicgs
dominicgs / shuffle.py
Created May 24, 2016 00:29
Perfect card shuffling example
#!/usr/bin/env python
decks = [range(1, 53)]
def shuffle(deck):
a = deck[:len(deck)/2]
b = deck[len(deck)/2:]
c = zip(a, b)
return c
@dominicgs
dominicgs / piconet.py
Created March 3, 2016 22:10
Bluetooth hopping pattern implementation
#!/usr/bin/env python
# Copyright 2016 Dominic Spill, Michael Ossmann, Will Code
BT_NUM_CHANNELS = 79
class Piconet(object):
def __init__(self, address):
self.address = address
self.sequence = []
@dominicgs
dominicgs / osmocom_spectrum_sense_flipdot.py
Last active August 29, 2015 14:27
Flipdot version of the osmocom_spectrum_sense (designed for MuCCC's UDP controller)
#!/usr/bin/env python
#
# Copyright 2005,2007,2011,2015 Free Software Foundation, Inc.
#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
diff --git a/host/cmake/modules/FindUSB1.cmake b/host/cmake/modules/FindUSB1.cmake
index 0cbf802..2f3138d 100644
--- a/host/cmake/modules/FindUSB1.cmake
+++ b/host/cmake/modules/FindUSB1.cmake
@@ -24,10 +24,15 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
pkg_check_modules(PC_LIBUSB libusb-1.0)
ENDIF(NOT WIN32)
+ set(LIBUSB_LIBRARY_NAME usb-1.0)
+ IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
@dominicgs
dominicgs / gist:eb43859f4239a8afdc78
Last active August 29, 2015 14:04
USB packet format for dot11 device
struct dot11_packet {
int32_t tv_sec;
int32_t tv_usec;
int dlt;
/* Channel we captured on, if available in packet headers, or channel we
* will tx on */
int channel;
/* Length of components */