Skip to content

Instantly share code, notes, and snippets.

Girgitt / arduino_compose_str_with_value.cpp
Created Nov 14, 2017
Adruino string and value concat
View arduino_compose_str_with_value.cpp
float v_s_r = analogRead(SUPP_VOLTAGE_PIN);
float supp_voltage = (5.0 / 1024) * v_s_r * 3.0;
String v_s = "supp_v:";
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);
Girgitt / char_string_equality.cpp
Created Nov 14, 2017
C++ char[] and String equality test function
View char_string_equality.cpp
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;
Girgitt /
Last active Nov 14, 2017
simple proxy to send/receive PJON messages over Redis pub/sub channel
import time
import redis
import logging
from pjon_python import over_redis_mock_client
from pjon_python import wrapper_client
Girgitt / pjon_winx86_arduino_test_client.ino
Created Apr 21, 2017
PJON WINX86 platform arduino code
View pjon_winx86_arduino_test_client.ino
#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
Girgitt / pjon_winx86_main.cpp
Created Apr 21, 2017
PJON WINX86 platform client code
View pjon_winx86_main.cpp
// 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>
Girgitt / PJON_,ultidrop_rs485_auto_tx_strategy
Last active Aug 21, 2016
A draft implementation of a multi-master strategy over RS485 "auto-tx" PHY for PJON protocol stack
View PJON_,ultidrop_rs485_auto_tx_strategy
/* 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.
View PJON_test_receiver.ino
#include <PJON.h>
// <Strategy name> bus(selected device id)
//PJON<SoftwareBitBang> bus(44);
PJON<OverSampling> bus(44);
void setup() {
pinModeFast(13, OUTPUT);
digitalWriteFast(13, LOW); // Initialize LED 13 to be off
View PJON_test_transmitter.ino
#include <PJON.h>
// <Strategy name> bus(selected device id)
//PJON<SoftwareBitBang> bus(45);
PJON<OverSampling> bus(45);
long start_ts;
void setup() {
Girgitt /
Created Jul 13, 2016
multithreaded sftp server in python based on
import time
import socket
import optparse
import sys
import textwrap
import paramiko
from sftpserver.stub_sftp import StubServer, StubSFTPServer