Skip to content

Instantly share code, notes, and snippets.

View JoelBender's full-sized avatar
🎯
Focusing

Joel Bender JoelBender

🎯
Focusing
View GitHub Profile
@JoelBender
JoelBender / whois_timer_sample.py
Created May 21, 2021 03:43
Periodically generate a Who-Is request
#!/usr/bin/env python
"""
This application generates a Who-Is request based on a timer, then lines up
the corresponding I-Am for incoming traffic and prints out the contents.
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
@JoelBender
JoelBender / local_objects.py
Created January 3, 2021 16:45
Local Objects
#!/usr/bin/env python
"""
This sample application is a server that has a local, writable, Analog Value
and Binary Value object.
On a network with two IPv4 workstations make a copy of the BACpypes~.ini file
called in BACpypes.ini and set the 'address:' to the CIDR address of the
workstation. For example, the first one is 192.168.10.11/24 and the second
is 192.168.10.21/24.
@JoelBender
JoelBender / simple_analog_values.py
Created October 20, 2020 02:31
Simple way of serving analog value objects
#!/usr/bin/env python
"""
This sample application shows how to create analog value objects with
different values.
"""
import os
import random
from bacpypes.primitivedata import TagList
from bacpypes.basetypes import (
DeviceObjectPropertyReference,
EventParameterAccessEventAccessEvent,
)
x = EventParameterAccessEventAccessEvent(
listOfAccessEvents=["deniedMaxAttempts"],
accessEventTimeReference=DeviceObjectPropertyReference(
objectIdentifier=("analogValue", 1), propertyIdentifier="presentValue"
@JoelBender
JoelBender / chips.py
Created April 29, 2020 13:24
Chips and wires
"""
Chips
"""
from typing import Any, List
_all_chips: List["Chip"] = []
_all_wires: List["Wire"] = []
@JoelBender
JoelBender / threading_1.py
Created April 17, 2020 01:09
Threading Examples
#!/usr/bin/python
"""
This application demonstrates doing something at a regular interval.
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ArgumentParser
@JoelBender
JoelBender / gist:0879b78ebc474502ada48870c51a266b
Created September 19, 2019 22:20
asyncio signal handler
import sys
import asyncio
import signal
def ctrl_c():
print("hit!")
sys.exit(1)
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, ctrl_c)
@JoelBender
JoelBender / who_is_and_device_info.py
Created September 10, 2019 13:43
Who-Is and Device Information
#!/usr/bin/env python
"""
This application generates a Who-Is request at startup and collects the I-Am
responses into a list, then reads various properties of the device objects,
then outputs the content as a JSON document.
"""
import sys
import json
# -*- coding: utf-8 -*-
import sys
from io import BytesIO
from rdflib import Graph
from pyshacl.validate import Validator
data = b"""
@prefix bakery: <http://bakery.com/ns#> .
@JoelBender
JoelBender / gist:c1c5c0dcd67a56f89869f48790d59927
Created January 31, 2019 02:52
aioamqp connection lost non-feature
"""
RPC server, aioamqp implementation of RPC examples from RabbitMQ tutorial
"""
import asyncio
import logging
import signal
import aioamqp
from aioamqp.protocol import AmqpProtocol