项目作者: akshmakov

项目描述 :
"COM"-Style Serial Port server with socat
高级语言: Shell
项目地址: git://github.com/akshmakov/serialport-server.git
创建时间: 2017-07-29T04:48:32Z
项目社区:https://github.com/akshmakov/serialport-server

开源协议:MIT License

下载


serialport-server

Simple Utility to Expose a local serial port on a network port, allowing for remote serial port access

Published on Dockerhub @ https://dockerhub.com/akshmakov/serialport-server

Requirements

  • socat

Usage

Start a server simply by

  1. $ ./serialport-server.sh /dev/ttyUSB0

Full Usage Information:

  1. Usage: serialport-server.sh [OPTIONS] device
  2. options:
  3. -p/--port=<PORT> : exposed TCP Port (default=2000)
  4. -b/--tty-br=<BAUDRATE> : baud rate of underlying device (default=9600)
  5. -l/--logfile=<FNAME> : save output to file
  6. -h/--help : print this usage
  7. -d/--daemon : daemonize (background)
  8. -v/--verbose : more (debug)
  9. device: local socket or device (e.g. /dev/ttyUSB0)
  10. The following Environment Variables can be used in lieu of args
  11. PORT - TCP Port
  12. BAUDRATE - Baudrate
  13. DEVICE - device

Usage - Docker

Docker container is available under dockerhub akshmakov/serialport-server:TAG, list of tags

  • latest amd64 container for standard x86_64 systems (alpine base)
  • arm32v7 armv7 systems (RPI 2/3)
  • arm32v6 armv6 systems (RPI 1 , comaptible with 2/3)
  • arm32v6-x.x.x, arm32v7-x.x.x, amd64-x.x.x Frozen Version Tags (These Tags will not be overwritten on DockerHub)

If you leave the tag off, the amd64 tag will be pulled

To start a dockerized serial port server on host port ‘2000’

  1. $ docker run -d -p "2000:2000" --device "/dev/ttyUSB0:/dev/ttyUSB0" akshmakov/serialport-server:latest /dev/ttyUSB0
  2. # test your server
  3. $ nc 127.0.0.1 2000

Usage - docker-compose

Start two serialport-servers using either command or environment variables

  1. version: '2'
  2. services:
  3. tty1:
  4. image: akshmakov/serialport-server
  5. devices:
  6. - "/dev/ttyUSB0:/dev/ttyUSB0"
  7. command: -b 19200 /dev/ttyUSB0
  8. ports:
  9. - "2000"
  10. tty2:
  11. image: akshmakov/serialport-server
  12. devices:
  13. - "/dev/ttyUSB1:/dev/ttyUSB1"
  14. environment:
  15. BAUDRATE:19200
  16. DEVICE:/dev/ttyUSB1

Client

Connect to a serialport server using a number of common terminals that accept a network socket.

Simplest use case is netcat, note that many terminal commands lik C-c will not work

  1. $ nc ip.of.serial.server 2000

using socom to provide a true tty (accepts ctrl-c

  1. $ socom file:'tty',raw,echo=0 tcp:ip.op.serial.server:2000,raw,echo=0

using picocom or minicom pointing them at the port

On windows, this server has been tested with realterm