Skip to content

Instantly share code, notes, and snippets.

Avatar
🤦‍♂️

Edward Beech initialed85

🤦‍♂️
View GitHub Profile
@initialed85
initialed85 / smbus_read_byte_protocol_with_synapse_wireless_snappy.py
Last active Jun 30, 2020
SMBus Read Byte protocol w/ Synapse Wireless Snappy
View smbus_read_byte_protocol_with_synapse_wireless_snappy.py
"""
Synapse Wireless RF200 devices use some terribly hobbled version of Python2 coupled with a terribly limited library.
They are in general terrible devices.
Anyway- to read SMBus (a protocol layer on top of i2c- see Page 41 of 85 of http://smbus.org/specs/SMBus_3_0_20141220.pdf) the process is as follows:
- write 2 bytes to i2c
- byte 0 = slave address shifted left by 1 bit, write bit of 0
- byte 1 = command
@initialed85
initialed85 / README.md
Last active Mar 31, 2022
Flashing Kogan (AU) smart devices w/ Tasmota using tuya-convert
View README.md

Flashing Kogan smart devices w/ Tasmota using tuya-convert

I bought the following devices from Kogan (AU):

  • KASB10WRGBCCTB22A Kogan SmarterHome 10W RGB+CCT Color & Warm/Cool White Smart Bulb (B22)
  • KALEPDLRGBCCTA Kogan SmarterHome Smart LED Downlight
  • KASB10WRGBCCTE27A Kogan SmarterHome 10W RGB+CCT Color & Warm/Cool White Smart Bulb (E27)
  • KASPEMHUSBA Kogan Smart Plug With Energy Meter (and 2 x USB)
    • NOTE: Same device as MS6104 Jaycar Smart Plug WiFi Controlled Main Switch and Energy Monitor with 2 x USB Sockets
@initialed85
initialed85 / gnss_test.py
Created Jan 22, 2020
Carla GNSS sensor oddities
View gnss_test.py
import glob
import os
import sys
import time
from math import sqrt
from pyproj import Geod, Transformer
try:
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
@initialed85
initialed85 / pktgen.py
Created Jan 15, 2020
Python packet generator
View pktgen.py
# to simulate DGPS generation
# python pktgen.py tb 3784 1 305
# to receive
# python pktgen.py rb 3784 1 305
# to simulate AMP generation
# python pktgen.py tm 13000 2.77 372
# to receive
# python pktgen.py rm 13000 2.77 372
@initialed85
initialed85 / something.py
Last active Jul 8, 2019
Example of custom Python3 pickling behaviour (should work with Python 2)
View something.py
from threading import RLock
class Something(object):
def __init__(self, a, b):
self.a = a
self.b = b
self._lock = RLock() # this is not pickleable
@initialed85
initialed85 / private_to_public.sh
Last active Jul 8, 2019
Create a public key for an AWS private key
View private_to_public.sh
#!/bin/bash
# props to original at https://gist.github.com/zircote/1243501
if [[ "${1}" == "" ]]; then
echo "usage: ${0} some_private_key.pem"
echo ""
echo "The result will be a public key at $(pwd)/some_private_key.pub"
exit 1
@initialed85
initialed85 / bsm.txt
Last active Feb 2, 2020
V2X safety/awareness message content (SAE BSM and ETSI CAM)
View bsm.txt
Here's one of SAE's BSMs in XER format (size units are centimetres apparently):
<BasicSafetyMessage>
<coreData>
<msgCnt>33</msgCnt>
<id>FEF0EFD0</id>
<secMark>51333</secMark>
<lat>-419231528</lat>
<long>158945769</long>
<elev>27</elev>
@initialed85
initialed85 / jython_example_magicdraw.py
Last active Mar 31, 2022
Example Jython script for NoMagic MagicDraw (Cameo Systems Modeler) metachain navigation
View jython_example_magicdraw.py
import pprint
def log(thing): # append to a log file
if not isinstance(thing, str):
text = repr(thing)
else:
text = thing
try:
@initialed85
initialed85 / app.py
Created Dec 17, 2018
Tkinter mock UI test example
View app.py
import datetime
import traceback
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel, QTextEdit
_STATE_LABEL_PREFIX = 'State: '
class WoWHMI(object):
@initialed85
initialed85 / acea_voltage_percentage.py
Last active Nov 28, 2018
Acea's voltage percentage thing
View acea_voltage_percentage.py
import re
data = """
Charge voltage 3.3V 3.5V 3.6V 3.7V 3.8V 3.9V 4.0V 4.05V 4.1V 4.15V 4.2V 4.25V * 4.3V*
Percentage of 4.2V 0 % 2.9 % 5.0 % 8.6 % 36 % 62 % 73 % 83 % 89 % 94 % 100 % 105 % 106%
"""
# grab only the first real line
interesting = data.strip().split('\n')[0]