Version 0.0.1

This commit is contained in:
Your Name
2025-09-28 11:05:26 -04:00
parent 7f8bc98b48
commit e018f30fdd
5 changed files with 304 additions and 29 deletions

View File

@@ -51,6 +51,9 @@ gcc -Wall -Wextra -std=c99 -O2 -o truerng main.c
- `-f, --format <FORMAT>` - Output format: binary, hex, base64, decimal
- Default: binary when piped, hex in interactive mode
- `-o, --output <FILE>` - Output filename (works with all formats)
- `-d, --device <DEVICE>` - Select specific device (index, port, or type)
- Examples: `1`, `/dev/ttyACM0`, `pro`, `prov2`, `truerng`
- `-l, --list` - List all available TrueRNG devices
- `-q, --quiet` - Suppress statistics/progress output
- `-v, --verbose` - Show detailed device information
- `-h, --help` - Show help message
@@ -65,23 +68,51 @@ The `-n` option supports convenient size suffixes (case-insensitive):
Decimal values are supported: `1.5MB`, `2.5GB`, etc.
### Device Selection
When multiple TrueRNG devices are connected, you can select a specific device using the `-d` option:
- **By index**: Use the device number from `--list` (e.g., `-d 1`, `-d 2`)
- **By port path**: Use the full device path (e.g., `-d /dev/ttyACM0`)
- **By device type**: Use device type keywords:
- `truerng` - Select original TrueRNG device
- `pro` - Select TrueRNGpro device
- `prov2` - Select TrueRNGproV2 device
```bash
# List all available devices
./truerng --list
# Use first device from list
./truerng -d 1 -n 1MB
# Use specific port
./truerng -d /dev/ttyACM1 -n 512K
# Use TrueRNGpro device
./truerng -d pro -n 2MB -f hex
```
### Examples
```bash
# Basic usage - interactive mode with hex output
./truerng
# Generate 1KB of data in hex format
# List available devices
./truerng --list
# Generate 1KB of data in hex format using first device
./truerng -n 1K -f hex
# Generate 2.5MB and pipe to another program
./truerng -n 2.5MB | xxd
# Generate 2.5MB using specific device and pipe to another program
./truerng -d 2 -n 2.5MB | xxd
# Save 1GB of binary data to file quietly
./truerng -n 1GB -o random.dat -q
# Save 1GB of binary data to file quietly using TrueRNGpro
./truerng -d pro -n 1GB -o random.dat -q
# Generate 512KB as hex and save to file
./truerng -n 512K -f hex -o output.hex
# Generate 512KB as hex and save to file using specific port
./truerng -d /dev/ttyACM0 -n 512K -f hex -o output.hex
# Generate base64 output with verbose device info
./truerng -n 1MB -f base64 -v
@@ -103,6 +134,14 @@ The program automatically detects the execution context:
- **Interactive mode**: Shows progress, statistics, and defaults to hex output
- **Piped mode**: Optimized for piping, defaults to binary output
- **File output**: Can be combined with any format using `-o` option
- **Multiple devices**: Automatically detects and warns when multiple devices are present
### Multiple Device Handling
When multiple TrueRNG devices are connected:
- Without `-d` option: Uses the first available device with a warning
- With `-d` option: Uses the specified device
- Use `--list` to see all available devices and their details
## Configuration
@@ -135,6 +174,14 @@ The C implementation:
## Sample Output
### Device Listing
```bash
./truerng --list
Available TrueRNG devices:
1. TrueRNGproV2 at /dev/ttyACM0 (VID:04D8 PID:EBB5)
2. TrueRNG at /dev/ttyACM2 (VID:04D8 PID:F5FE)
```
### Interactive Mode
```
TrueRNG - True Random Number Generator
@@ -155,6 +202,17 @@ Extra zeros: 48
=======
```
### Multiple Device Warning
```
Multiple TrueRNG devices found - using first available
(Use -d option to select specific device or --list to see all)
TrueRNG - True Random Number Generator
==================================================
TrueRNGproV2 Found
Using port: /dev/ttyACM0
...
```
### Piped Mode with Verbose
```
TrueRNG - True Random Number Generator
@@ -193,13 +251,24 @@ Options:
Supports suffixes: K, MB, GB, TB (e.g., 1K, 2.5MB, 1GB)
-f, --format <FORMAT> Output format: binary, hex, base64, decimal (default: binary when piped, interactive otherwise)
-o, --output <FILE> Output filename (ignored in piped mode)
-d, --device <DEVICE> Select specific device (index, port, or type)
Examples: 1, /dev/ttyACM0, pro, prov2
-l, --list List all available TrueRNG devices
-q, --quiet Suppress statistics/progress
-v, --verbose Show detailed device information
-h, --help Show this help message
Device Selection:
When multiple devices are present, use -d to select:
-d 1 Select first device from list
-d /dev/ttyACM1 Select by port path
-d pro Select TrueRNGpro device
-d prov2 Select TrueRNGproV2 device
-d truerng Select original TrueRNG device
Examples:
truerng -n 1024 -f hex # Interactive mode with hex output
truerng -n 1K -f hex # Same as above using K suffix
truerng -n 2.5MB | xxd # Piped mode with MB suffix
truerng -n 1GB -o random.dat -q # Save 1GB to file quietly
truerng -n 512K -f hex -o output.hex # Save 512KB as hex to file
truerng --list # List available devices
truerng -n 1K -f hex # Use first available device
truerng -d 2 -n 1MB # Use second device from list
truerng -d /dev/ttyACM1 -n 512K # Use specific port
truerng -d pro -n 1GB -o random.dat # Use TrueRNGpro device