Skip to content

Instantly share code, notes, and snippets.

Comparison

  • TCP:

    • Connection based
    • Guaranteed reliable and ordered
    • Automatically breaks up your data into packets for you
    • Makes sure it doesn’t send data too fast for the internet connection to handle (flow control)
    • Easy to use, you just read and write data like its a file
  • UDP:

@taotao
taotao / pymodbus_rtu.py
Created October 6, 2016 07:57
Use pymodbus to access modbus rtu device
#!/usr/bin/env python
from pymodbus.client.sync import ModbusSerialClient
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
client = ModbusSerialClient(method='rtu', port='/dev/ttyM0', baudrate=38400, parity='N', bytesize=8, stopbits=1, timeout=1)
@taotao
taotao / pyserial.py
Created October 6, 2016 07:55
Use pyserial to send serial data
#!/usr/bin/env python
import serial
import binascii
ser=serial.Serial('/dev/ttyM0', baudrate=38400, timeout=1)
ser.write(binascii.unhexlify('010200010001e80a'))
r = ser.read(16)
if r is not None:
print repr(binascii.hexlify(r))
@taotao
taotao / build-raspbian-image.md
Created June 16, 2016 11:00
Build Your Own Raspbian Image

General

Check AT command

at

Check PIN code

at+cpin?

Enter PIN code (pin code = 0000)

at+cpin=0000

Get Signal

qmicli -d /dev/cdc-wdm0 -p --nas-get-signal-strength

PIN Code unlock (PIN=0000)

qmicli -d /dev/cdc-wdm0 -p --dms-uim-verify-pin=PIN,0000

Dial-up (APN=internet)

qmicli -d /dev/cdc-wdm0 -p --wds-start-network=internet --client-no-release-cid --device-open-net='net-802-3|net-no-qos-header'

Release CID

@taotao
taotao / xetex-example.tex
Created March 21, 2016 11:46
xetex sample to write in 中文
%%%
%%% Prepare Chinese Font of 微軟正黑體
%%%
%%% Make PDF file:
%%% xelatex xetex-sample.tex
%%%
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont[BoldFont=msjhbd.ttf]{msjh.ttf}
@taotao
taotao / Debian_Mail_Server_with_Anti-Virus.md
Last active January 13, 2021 12:50
Debian Exim4 mail server with Clamav support.

Environment

  • Debian: Jessie
  • Mail Server: Exim
  • Anti-Virus: Clamav

Install packages

  1. apt-get install clamav clamav-daemon exim4-daemon-heavy

Configuration of Clamav

  1. Modify /etc/clamav/clamd.conf
@taotao
taotao / build-ovpn-server.sh
Last active March 10, 2016 03:54
OpenVPN Test Server Setup Script
#!/bin/sh
set -e
if [ "$#" -ne 1 ]; then
echo "Need parameter for HOST IP/NAME."
fi
MY_HOST=$1
cd /etc/openvpn