a lot of fixes

This commit is contained in:
2026-11-17 09:21:59 +03:00
parent 58a489f1ad
commit c8ee17854d
15 changed files with 316 additions and 173 deletions

View File

@@ -61,37 +61,40 @@ modbus_params [options]
| Option | Argument | Description |
|--------|-------------------|-------------|
| `-h`, `--help` | – | Show help and exit |
| `-v`, `--verbose` | – | Increase verbosity (can be used multiple times) |
| `-D`, `--dictionary` | *file* | Dictionary file (format: `code register value readonly`). *Required for most operations.* |
| `-a`, `--alias` | *file* | Aliases file (format: `name : command`). Optional. |
| `-s`, `--slave` | *ID* | Modbus slave ID (default: 1) |
| `-d`, `--device` | *path* | Serial device (default: `/dev/ttyUSB0`) |
| `-b`, `--baudrate` | *rate* | Baud rate (default: 9600) |
| `-d`, `--device` | *path* | Serial device (default: `/dev/ttyUSB0`) |
| `-D`, `--dictionary` | *file* | Dictionary file (format: `code register value readonly`). *Required for most operations.* |
| `-f`, `--format` | *fmt* | Serial port format: databitss parity stopbits (default: "8N1") |
| `-h`, `--help` | – | Show help and exit |
| `-s`, `--slave` | *ID* | Modbus slave ID (default: 1) |
| `-v`, `--verbose` | – | Increase verbosity (can be used multiple times) |
### Read/write operations
| Option | Description |
|--------|-------------|
| `-C`, `--clone` | Write all read-write entries of the `-D` dictionary to the device. Read-only entries are skipped. On completion prints written N, errors M.|
| `-O`, `--outdic` *file* | Read **all** registers listed in the dictionary and save them (with current values) into a new dictionary file |
| `-r`, `--readr` *addr* | Read register by address (multiply: `-r 100 -r 200`) |
| `-R`, `--readc` *code* | Read register by dictionary code (multiply) |
| `-w`, `--writer` *addr=val* | Write value to register by address (multiply) |
| `-W`, `--writec` *code=val* | Write value to register by dictionary code (multiply) |
| `-O`, `--outdic` *file* | Read **all** registers listed in the dictionary and save them (with current values) into a new dictionary file |
### Discrete I/O sizes
| Option | Argument | Description |
|--------|-------------------|-------------|
| `-i`, `--inputs` | N | Number of bytes for discrete inputs (default: 1) |
| `-c`, `--coils` | N | Number of bytes for coils/outputs (default: 1) |
| `-i`, `--inputs` | N | Number of bytes for discrete inputs (default: 1) |
### Dumping (periodic TSV output)
| Option | Description |
|--------|-------------|
| `-k`, `--dumpkey` *code* | Add a dictionary key to the dump list (multiply) |
| `-o`, `--outfile` *file* | TSV file for the dump |
| `-o`, `--outfile` *file* | TSV file for the dump (path relative to `/tmp/`) |
| `-t`, `--dumptime` *seconds* | Dump interval (default: 0.1 s) |
### Server mode
@@ -120,7 +123,7 @@ Format:
- `value` – initial/default value (16‑bit, not used by the tool except for documentation).
- `readonly` – `0` (writable) or `1` (read‑only).
Example (from `dictionary.dic`):
Example (from `ESQ770.dic`):
```
F00.00 61440 1 0 # Motor management (V/F)
@@ -169,6 +172,8 @@ Example:
0.102 1 5000
```
For sequrity reasons dump file name is relative to `/tmp` and shouldn't have `../` inside.
## Server protocol
The server listens for plain text commands, terminated by newline (`\n`).
@@ -260,19 +265,19 @@ readinputs[0] = 1
### 1. Simple read by address
```bash
modbus_params -D dictionary.txt -s 1 -d /dev/ttyUSB0 -b 9600 -r 61440
modbus_params -D dictionary.dic -s 1 -d /dev/ttyUSB0 -b 9600 -r 61440
```
### 2. Write a value using a code
```bash
modbus_params -D dictionary.txt -W "F00.00=1"
modbus_params -D dictionary.dic -W "F00.00=1"
```
### 3. Dump two registers every 0.5 seconds to `data.tsv`
```bash
modbus_params -D dictionary.txt -k F00.00 -k F00.11 -o data.tsv -t 0.5
modbus_params -D dictionary.dic -k F00.00 -k F00.11 -o data.tsv -t 0.5
```
(No server started – the program will dump until interrupted.)
@@ -280,7 +285,7 @@ modbus_params -D dictionary.txt -k F00.00 -k F00.11 -o data.tsv -t 0.5
### 4. Start a local server with dumping already active
```bash
modbus_params -D dictionary.txt -k F00.00 -o /tmp/dump.csv -t 1 -N localhost:5020
modbus_params -D dictionary.dic -k F00.00 -o /tmp/dump.csv -t 1 -N localhost:5020
```
Now you can connect to port 5020 and use `newdump` to change the output file, or `clodump` to stop.