Virtual serial line on linux with socat, python server & client
socat -d -d pty,raw,echo=0,link=/tmp/cryocon_simulator pty,raw,echo=0,link=/tmp/cryocon
""" | |
A gevent friendly version of inotify | |
Either instanciate Inotify (or InotifyTree) objects directly from `ginotify.Inotify`: | |
```python | |
from ginotify import Inotify | |
ify1 = Inotify() |
""" | |
A gevent friendly version of inotify_simple | |
Either instanciate INotify objects directly from `ginotify_simple.INotify`: | |
```python | |
from ginotify_simple import INotify, flags | |
ify1 = INotify() |
import asyncio | |
import serial_asyncio | |
I=0 | |
async def loop(): | |
global I | |
while True: | |
await asyncio.sleep(0.1) | |
I += 1 |
import os | |
import sys | |
import time | |
import threading | |
from tango.server import Device, attribute, command | |
attrs = [ | |
dict(name='voltage', dtype=float, label='Voltage', fget=lambda dev: 1.2345), | |
dict(name='power_level', dtype=str, label='Power level', fget=lambda d: 'high') |
""" | |
Example output: | |
2020-05-05 20:04:47,200 trying to connect to bl04cryocon:5000 | |
2020-05-05 20:04:47,701 error: TimeoutError() | |
2020-05-05 20:04:47,702 trying to connect to bl04cryocon:5000 | |
2020-05-05 20:04:48,203 error: TimeoutError() | |
2020-05-05 20:04:48,204 trying to connect to bl04cryocon:5000 | |
2020-05-05 20:04:48,706 error: TimeoutError() | |
2020-05-05 20:04:48,707 trying to connect to bl04cryocon:5000 |
# Execute with sudo | |
# Recipe at: https://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad | |
NAME=bl04-eth | |
ALIAS=$NAME:0 | |
MAC=00:22:22:ff:ff:ff | |
IP=192.168.100.199 | |
# Create interface | |
ip link add $NAME type dummy |
# find hosts with port 80 open
nmap -PE -p 80 xxx.yyy.zzz.*
""" | |
requirements: | |
$ pip install click | |
run with: | |
$ python tcp_proxy --listen=:5000 --connect=192.168.1.100:5000 | |
""" | |
import socket |