Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foldl/kissuart
A serial port terminal (for Windows) based on KISS principle
https://github.com/foldl/kissuart
erlang uart
Last synced: 4 days ago
JSON representation
A serial port terminal (for Windows) based on KISS principle
- Host: GitHub
- URL: https://github.com/foldl/kissuart
- Owner: foldl
- License: mit
- Created: 2014-06-04T08:25:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-11-05T08:18:50.000Z (over 2 years ago)
- Last Synced: 2025-02-04T16:08:48.085Z (10 days ago)
- Topics: erlang, uart
- Language: C
- Size: 29.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KissUART
A serial port utility (for Windows) based on K.I.S.S. principle.
This can be built into a command line tool, an Erlang port, or a DLL as needed.
# Build
Batch file using GCC is provided. It's would be simple to use another compiler
instead.* A stand alone executable: `build.bat EXE`
* An Erlang port: `build.bat PORT`
* A DLL: `build.bat DLL`
# Usage
## A stand alone executable
```
UART port options:
-port (mandatory)
-baud
-databits
-stopbits
-parity none | even | odd | mark | space
Common options:
-help/-? show this
-hex use hex display
-timestamp display time stamp for output default: OFF
-async_io use win32 async IO operations default: OFF
-cr cr | lf | crlf | lfcr default: cr
-input string | charNote: string: based on 'gets' (default),
can use UP/DOWN to access input history
char : based on 'getch' (low level)
```### A Tip on ^Z
When string mode (default) is used, ^Z could save ^Z into the output buffer, and another is needed to
write it to COM port.## An Erlang port
This Erlang port uses the exactly the same command line options as the stand alone executable, except that some common
options are obviously not avaliable.### Example: uart2tcp
`socat` is powerful Linux tool, which can let other programs access an uart port
just like a TCP port. On Windows, it is much easier to build our own wheel than
to search a similar tool. See [`uart2tcp.erl`](uart2tcp.erl).## A DLL
Only 5 APIs are exported by this DLL. Below is Pascal (Delphi/Lazarus) code for reference.
```Pascal
typeTUartObj = Pointer;
TCommCloseReason = (ccShutdown, ccError);
TOnCommRead = procedure (Param: Pointer; const P: PByte; const L: Integer);
TOnCommClose = procedure (Param: Pointer; const Reason: TCommCloseReason);function UartOpen(Uart: TUartObj;
const PortNumber: Integer;
const Baud: Integer;
const Parity: PChar;
const DataBits: Integer;
const StopBits: Integer;
OnCommRead: TOnCommRead;
CommReadParam: Pointer;
OnCommClose: TOnCommClose;
CommCloseParam: Pointer;
AsyncIO: Boolean): TUartObj; stdcall;
external 'uart.dll' name 'uart_open';procedure UartSend(Uart: TUartObj;
const Buf: PByte;
const L: Integer); stdcall; external 'uart.dll' name 'uart_send';procedure UartShutdown(Uart: TUartObj); stdcall; external 'uart.dll' name 'uart_shutdown';
function GetUartObjSize: Integer; stdcall; external 'uart.dll' name 'get_uart_obj_size';
function UartConfig(Uart: TUartObj;
const Baud: Integer;
const Parity: PChar;
const DataBits: Integer;
const StopBits: Integer): Integer; stdcall; external 'uart.dll' name 'uart_config';
```