This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import random | |
import string | |
# Function to generate random text of length 32 | |
def generate_random_text(): | |
return ''.join(random.choices(string.ascii_letters + string.digits, k=32)) | |
# Generate a list of a couple of hundred random text values | |
random_text_list = [generate_random_text() for _ in range(400000)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import time | |
import datetime | |
import argparse | |
from sys import exit | |
from pathlib import Path | |
from typing import Iterator, Tuple | |
from shutil import disk_usage, rmtree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfilerLog(object): | |
def __init__(self, profiler_name="", start_ts=None): | |
self._profiler_name = profiler_name | |
self._start_ts = start_ts if start_ts else time.time() | |
self._steps_data = OrderedDict() | |
self._aux_data = {} | |
def step(self, step_name, begin_ts=None, end_ts=None): | |
if step_name not in self._steps_data: | |
begin_ts = begin_ts if begin_ts else time.time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes | |
class Encryption(object): | |
def __init__(self, key='aKeyNobodyWIllEverUse', nonce='PleaseMakeMeRandomEachTime'): | |
key = str(key) | |
while len(key) < 32: | |
key += key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float v_s_r = analogRead(SUPP_VOLTAGE_PIN); | |
float supp_voltage = (5.0 / 1024) * v_s_r * 3.0; | |
String v_s = "supp_v:"; | |
v_s.concat(supp_voltage); | |
int v_s_str_len = v_s.length() + 1; //we need extra space for the null terminator thus len += 1 | |
char v_s_send[v_s_str_len]; | |
v_s.toCharArray(v_s_send, v_s_str_len); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool payload_str_equality(const uint8_t *n_one, String cmp_str, uint16_t length) { | |
char cmd_check[length + 1]; | |
cmp_str.toCharArray(cmd_check, length + 1); | |
for (uint8_t i = 0; i < length; i++) | |
if (n_one[i] != cmd_check[i]) | |
return false; | |
return true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import redis | |
import logging | |
from pjon_python import over_redis_mock_client | |
from pjon_python import wrapper_client | |
logging.basicConfig() | |
logging.getLogger().setLevel(logging.DEBUG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <PJON.h> | |
// <Strategy name> bus(selected device id) | |
PJON<ThroughSerial> bus(44); | |
void setup() { | |
pinMode(13, OUTPUT); | |
digitalWrite(13, LOW); // Initialize LED 13 to be off | |
Serial.begin(115200); | |
bus.strategy.set_serial(&Serial); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pjon_compile_test.cpp : Defines the entry point for the console application. | |
// | |
#include "stdafx.h" | |
#include <stdio.h> | |
#include <iostream> | |
// PJON library | |
#include <inttypes.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ThroughHardwareSerialRs485AutoTx enables PJON multi-master communication through the Serial port with auto-tx RS485 PHY. | |
Work based on ThroughHardwareSerial by Giovanni Blu Mitolo and Fred Larsen | |
Copyright (c) 2016 by Zbigniew Zasieczny All rights reserved. | |
With rs485 "auto-tx" PHY the hardware serial port reads everything sent to the bus | |
The "self-reading" property could be used in this strategy to detect colisions at a byte-level in a similar way the CAN network works on a bit-level to silelntly drop-off lower priority nodes; feature not implemented yet | |
A naive timeout-based collision avoidance is used: bus is assumed clear for tx within specified time window after empty rx buffer was detected. The receive(<timeout_us>) function must be called often - transimission would occur only within 1ms after last receive call on empty rx buffer; within this time window the update() function must be called to transmit packets. |
NewerOlder