Skip to content

Instantly share code, notes, and snippets.

View sjlongland's full-sized avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / gist:7ef0f7cb7a5a2c76e686701889110f18
Created January 2, 2019 21:14
JSON blob of configuration data
{
"cs": {
"p": 123,
"m": "a",
"a": "2001:db8:aaaa:bbbb::101"
},
"ts": {
"c": {
"c1": [
"p"
@sjlongland
sjlongland / gist:007d0385b1f6cd2b37c0192a2ce0cecc
Created March 2, 2018 04:16
BACnet connection management
# MeterMaster Data Access Layer
# (C) 2017 VRT Systems
#
# The following Software is the proprietary property of VRT Systems.
# Unauthorised disclosure or use of this Software is forbidden to the extent
# permitted by law.
#
# vim: set ts=4 sts=4 et tw=78 sw=4:
from threading import Event, Semaphore, Thread
@sjlongland
sjlongland / test.sh
Created February 7, 2018 02:09
pika test case: channel close bug
#!/bin/sh -ex
: ${PYTHON2:=$( which python2 )}
: ${PYTHON3:=$( which python3 )}
pass=""
fail=""
for python in ${PYTHON2} ${PYTHON3}; do
for pika in 0.9.14 0.10.0 0.11.2; do
@sjlongland
sjlongland / radio.c
Last active January 8, 2018 06:07
Debugging the CC2538 radio driver.
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@sjlongland
sjlongland / README.md
Created December 21, 2017 05:43
syslogd implementation for OpenThread

RFC 5424 compatible syslog implementation for OpenThread.

This requires:

  • a filesystem of some kind, with stubs for newlib's file I/O functions… we're using SPIFFS with a SPI EEPROM, but there are lots of options.
  • a real-time clock with an implementation of gettimeofday… we use a NXP PCF8523 I²C RTC to synchronise a software counter

If sending of a message fails (because buffers are full) and the message severity is high enough,

@sjlongland
sjlongland / connection.py
Last active December 17, 2017 23:31
Integrating bacpypes into tornado
# MeterMaster Data Access Layer
# (C) 2017 VRT Systems
#
# The following Software is the proprietary property of VRT Systems.
# Unauthorised disclosure or use of this Software is forbidden to the extent
# permitted by law.
#
# vim: set ts=4 sts=4 et tw=78 sw=4:
from threading import Event, Semaphore, Thread
@sjlongland
sjlongland / haystack2dot.py
Last active June 26, 2018 03:46
Visualising Project Haystack graphs using pyhaystack and graphviz
#!/usr/bin/env python
# Dump a Project Haystack tree to a graphviz `dot` file.
# Example usage:
# python haystack2dot.py --client-type widesky --client-uri http://localhost:8084 \
# --client-username user@example.com --client-password password \
# --client-id aaaaaaaa --client-secret bbbbbbbb \
# --filter 'equipRef==@vrtsofteng.db1_ac1 and (point or modbusBlock or modbusReserved)' \
# --filter 'device2Ref==@vrtsofteng.db1_ac1' \
# --filter 'device2Ref==@vrtsofteng.vrtems_gw' \
@sjlongland
sjlongland / log
Created November 28, 2017 00:43
Attempt at overflow handling in readFrame…
[DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
[INFO]-PLAT----: ExtAddr=FE334F746B3E6F1E
[INFO]-PLAT----: ShortAddr=FFFE
[DEBG]-PLAT----: Clear ShortAddr entries
[DEBG]-PLAT----: Clear ExtAddr entries
[DEBG]-MAC-----: SrcAddrMatch - Cleared all entries
[INFO]-PLAT----: Initialized
[DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
@sjlongland
sjlongland / radio.c mods
Created November 27, 2017 08:29
OpenThread CC2538 radio module bug investigation
stuartl@vk4msl-ws ~/vrt/projects/widesky/hub/hal $ diff -u third_party/openthread/examples/platforms/cc2538/radio.c src/radio.c
--- third_party/openthread/examples/platforms/cc2538/radio.c 2017-08-01 12:48:31.466864595 +1000
+++ src/radio.c 2017-11-27 15:09:30.067050133 +1000
@@ -73,23 +73,20 @@
uint8_t mTxPowerReg;
} TxPowerTable;
-// The transmit power table, the values are from SmartRF Studio 2.4.0
+// The transmit power table, the values are from application note 130
static const TxPowerTable sTxPowerTable[] =
@sjlongland
sjlongland / gist:192f74feb04cbce7c5929c91021f2cfa
Created November 24, 2017 09:02
OpenThread CC2538 TX issue, possible fix
stuartl@vk4msl-ws ~/vrt/projects/widesky/hub/hal $ diff -u third_party/openthread/examples/platforms/cc2538/radio.c src/radio.c
--- third_party/openthread/examples/platforms/cc2538/radio.c 2017-08-01 12:48:31.466864595 +1000
+++ src/radio.c 2017-11-24 18:56:04.074493486 +1000
@@ -73,23 +73,20 @@
uint8_t mTxPowerReg;
} TxPowerTable;
-// The transmit power table, the values are from SmartRF Studio 2.4.0
+// The transmit power table, the values are from application note 130
static const TxPowerTable sTxPowerTable[] =