Skip to content

Instantly share code, notes, and snippets.

@agners
agners / serial_asyncio_test.py
Created April 2, 2022 10:36
Test serial_asyncio with socat
import asyncio
import serial_asyncio
import serial
class Output(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
print('port opened', transport)
# This causes an exception
#transport.serial.rts = False
@agners
agners / README.md
Created February 22, 2022 13:33
Silicon Labs OpenThread native git repositories

Silicon Labs OpenThread native git repositories

Background: Silicon Labs offers OpenThread with modifications to support multi-protocol operations as described in AN1333. At least since Gecko SDK release 4.0.0 (Silicon Labs OpenThread release 2.0.0.0) the OpenThread repositories are available through their unified Gecko SDK releases at https://github.com/siliconLabs/gecko_sdk.

However, this repositories has several flaws:

  • It combines all their SDKs in a single big repository
@agners
agners / esp32-c3.yaml
Last active January 2, 2022 11:18
ESPHome ESP32-C3 configuration
# This is a ESPHome yaml configuration skeleton for
# ESP32-C3 (RISC-V) based boards.
# It is known to work on ESP32-C3-DevKitM-1
# This is using stable release of Arduino 2.0.2 as base
esphome:
name: esp32-c3-test
platformio_options:
board_build.flash_mode: dio
@agners
agners / cp2102n-qfn20-gpio-ctrlep.py
Created May 28, 2021 17:31
Control CP2102N GPIO by using pyusb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Stefan Agner
import os
import sys
import time
import usb
CP210X_VENDOR_SPECIFIC = 0xFF
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import time
import usb
ftdi_eval = {
'tty': "/dev/ttyUSB3",
@agners
agners / update_bytecode_timestamps.py
Created January 28, 2019 15:12
Update Python3 bytecode timestamps
#!/usr/bin/python3
# Python scripts which reads all Python bytecode files (pyc) and clears
# the timestamp (set to 0)
# This is useful for OSTree which clears modification time of all source
# files. Processed bytecode files are then not considered stale anymore.
import sys, os
import marshal
import importlib.util
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Stefan Agner
import os
import sys
import time
import usb
BITMODE_CBUS = 0x20
@agners
agners / main.c
Last active May 24, 2017 04:42 — forked from mlubin/newton.jl
i.MX 7 Cortex-M4 FreeRTOS C micro benchmark
#include <math.h>
#include "FreeRTOS.h"
#include "task.h"
#include "board.h"
#include "debug_console_imx.h"
double squareroot(double x)
{
double it = x;
while (fabs(it*it - x) > 1e-13) {
@agners
agners / container.go
Last active March 12, 2017 23:03 — forked from 17twenty/container.go
Containerisation in 100 Lines of Go Code
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@agners
agners / sort.c
Created November 2, 2013 23:11
quicksort/mergesort implementation in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ELEMENTS 100
void quicksort(int array[], int left, int right);
void mergesort(int array[], int length);
void printarray(int array[], int length)