Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,46 @@ This script is quite chatty in the console, to let you see exactly what is going
It is not supposed to be exhaustive, but rather to demonstrate a basic set of functionality to get you started with the device.

Supported Readers:
* GM65 (and GM65S)
* GM65 (and GM65S)
* GM805
* M3Y-W

_All of the commands below first attempt to auto-detect the reader you are using..._

There are also some manuals for these devices in the manuals folder of this repository.

## Command Support Matrix

The following table shows which commands are supported by each scanner implementation:

| Command | GM65/GM805 | M3Y-W | Notes |
|---------|------------|-------|-------|
| **Query Commands** | | | |
| `--hw-version` | ✅ Supported | ❌ Not Supported | M3Y-W only has firmware version |
| `--sw-version` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--sw-year` | ✅ Supported | ❌ Not Supported | M3Y-W doesn't separate year |
| `--get-settings` | ✅ Supported | ❌ Not Supported | M3Y-W uses individual commands |
| **Configuration Commands** | | | |
| `--set-settings` | ✅ Supported | ❌ Not Supported | M3Y-W uses individual commands |
| `--save-settings` | ✅ Supported | ❌ Not Supported | M3Y-W auto-saves settings |
| `--set-illumination` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-aimer` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-beeper` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-read-interval` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-same-barcode-delay` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-continuous-mode` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-command-mode` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--set-baudrate` | ✅ Supported | ✅ Supported | Available on all scanners |
| **Utility Commands** | | | |
| `--send-raw-cmd` | ✅ Supported | ✅ Supported | Available on all scanners |
| `--test-baudrates` | ✅ Supported | ✅ Supported | Available on all scanners |

**Legend:**
- ✅ **Supported**: Command is implemented and works with this scanner
- ❌ **Not Supported**: Command is not available for this scanner type (returns "Not Supported" message)

**Note**: When a command is not supported by a scanner, the tool will display a clear "Not Supported" message rather than failing silently.

# Setup
## Requirements
This module uses pyserial, so that needs to be installed via pip
Expand Down
14 changes: 14 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool:pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts =
-v
--tb=short
--strict-markers
--disable-warnings
markers =
integration: marks tests as integration tests (require real hardware)
unit: marks tests as unit tests (no hardware required)
slow: marks tests as slow running
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Core dependencies
pyserial>=3.5

# Testing dependencies
pytest>=7.0.0
49 changes: 49 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""
Test runner script for SerialBarcodeReaderTools

Usage:
python run_tests.py # Run unit tests only
python run_tests.py --integration # Run integration tests (requires hardware)
python run_tests.py --all # Run all tests
"""

import sys
import subprocess
import argparse


def run_command(cmd):
"""Run a command and return the result."""
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd)
return result.returncode


def main():
parser = argparse.ArgumentParser(description="Run tests for SerialBarcodeReaderTools")
parser.add_argument("--integration", action="store_true",
help="Run integration tests (requires real GM65 hardware on /dev/ttyACM0)")
parser.add_argument("--all", action="store_true",
help="Run all tests including integration")

args = parser.parse_args()

# Base pytest command
cmd = ["python", "-m", "pytest", "-v"]

if args.integration:
cmd.extend(["-m", "integration"])
print("Running integration tests (requires GM65 scanner on /dev/ttyACM0)...")
elif args.all:
print("Running all tests...")
else:
# Run only unit tests (exclude integration)
cmd.extend(["-m", "not integration"])
print("Running unit tests only...")

return run_command(cmd)


if __name__ == "__main__":
sys.exit(main())
Loading