Skip to content

Instantly share code, notes, and snippets.

@arberg
arberg / linuxRedirectSerialPortToTcpWithLog.sh
Last active November 25, 2018 15:39
In linux redirect RS232 Serial Port traffic (in+out) to TCP port. Log all input + output to files. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
#!/bin/bash
pid=$$
pgid=$(ps -o pgid= $$ | awk '{$1=$1;print}')
# netcat -l 7000 </dev/ttyUSB0 >/dev/ttyUSB0 &
cat /dev/ttyUSB0 | tee /var/log/lyngdorfSerial.ComToTcp.log | netcat -l 7000 | tee /var/log/lyngdorfSerial.TcpToCom.log > /dev/ttyUSB0 &
# Linux resets state when netcat closes com-port, so we need to se this after opening netcat
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb -echo
@arberg
arberg / linuxRedirectSerialPortToTcpWithLog.sh
Created November 25, 2018 10:23
In linux redirect RS232 Serial Port traffic (in+out) to TCP port. Log all input + output to files. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
#!/bin/bash
# netcat -l 7000 </dev/ttyUSB0 >/dev/ttyUSB0 &
cat /dev/ttyUSB0 | tee /var/log/lyngdorfSerial.ComToTcp.log | netcat -l 7000 | tee /var/log/lyngdorfSerial.TcpToCom.log > /dev/ttyUSB0 &
# Linux resets state when netcat closes com-port, so we need to se this after opening netcat
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb
killtree() {
@arberg
arberg / WindowsHub4ComSerialRedirectToTcpPortWithTraceAndBaudRate.cmd
Last active November 25, 2018 10:17
In windows redirect RS232 Serial Port traffic (in+out) to TCP port. Its possible to connect with telnet to tcp-port. Short circuit COM pin 2+3 (in+out) to do loop-back test of connection without device attached, see http://www.ni.com/tutorial/3450/en/
del log\*.log
rem Dependent on Hub4Com
rem Hub4Com Project page and download
rem https://sourceforge.net/projects/com0com/files/hub4com/
rem https://sourceforge.net/p/com0com/news/2012/06/hub4com-v2100-released/
rem Parent com0com project page (unused)
rem https://sourceforge.net/projects/com0com/
@arberg
arberg / Get-TodoistBackup.ps1
Last active June 11, 2018 19:21 — forked from dansmith65/Get-TodoistBackup.ps1
Powershell script to download the latest backup from Todoist - With logging and win10 notifications on failure
# Get-TodoistBackup.ps1
# Created By: Daniel Smith dan@dansmith65.com
#
# Download the latest backup from Todoist
#
# https://gist.github.com/dansmith65/7a753ddb89c9db145d41b0c4b3c7fac0
# https://gist.github.com/arberg/5c905272dd3ba41d767e0907b46cd675
# Powershell Notifications: Install-Module -Name BurntToast
$useToast=(Get-Command New-BurntToastNotification -errorAction SilentlyContinue)
@arberg
arberg / gw-simple.ps1
Last active May 7, 2022 02:46
Wrapping the gradle wrapper with Powershell
#Finds the first gradle in the list below
#Runs gradle with the arguments to this script in current dir
$gradlePaths = @("./gradlew","../gradlew", "gradle")
$currentGradlePaths = ( $gradlePaths | ?{ gcm $_ -erroraction 'silentlycontinue' } )
if ($currentGradlePaths.Length -gt 0) {
if ($currentGradlePaths -is [array]) {
$gradle = $currentGradlePaths[0]
} else {
@arberg
arberg / MyActivity.Java
Created February 1, 2018 14:20
RxJava with AutoDispose: Provoke error after life cycle ends
package dk.bnr.androidbooking;
import android.arch.lifecycle.Lifecycle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.uber.autodispose.AutoDispose;
import com.uber.autodispose.AutoDisposePlugins;
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
@arberg
arberg / Apache Tomcat 8 Start stop script init.d script
Last active October 17, 2018 18:12 — forked from miglen/Apache Tomcat 8 Start stop script init.d script
Apache Tomcat init script (or startup/controll script). Works fine for version 7/8. Read the comments for release history. Feel free to modify, copy and give suggestions. (c) GNU General Public License
#!/bin/bash
#
# description: Apache Tomcat init script
# processname: tomcat
# chkconfig: 234 20 80
#
#
# Copyright (C) 2014 Miglen Evlogiev
#
# This program is free software: you can redistribute it and/or modify it under