Skip to content

Instantly share code, notes, and snippets.

View tomasinouk's full-sized avatar

Tomas Blaha tomasinouk

View GitHub Profile
@oysstu
oysstu / crc16.py
Last active November 29, 2023 12:38
Implementation of crc16 (CRC-16-CCITT) in python
def crc16(data: bytes, poly=0x8408):
'''
CRC-16-CCITT Algorithm
'''
data = bytearray(data)
crc = 0xFFFF
for b in data:
cur_byte = 0xFF & b
for _ in range(0, 8):
if (crc & 0x0001) ^ (cur_byte & 0x0001):
@nfarring
nfarring / uartbert.py
Created November 9, 2011 01:06
Serial Bit Error Rate Tester in Python
#!/usr/bin/env python
#
# Measure the bit error rate if a serial port in loopback.
#
import serial
import sys
import traceback