Serial Server HTTP Service with ABAP integration
Project description
SerialSrv
A Python HTTP service that reads data from serial ports and provides it via REST API with ABAP integration support. by Altay Kireççi opriori (c)(p) 2025-09 https://www.opriori.com
Features
- 🔌 Serial Port Reading: Read data from Arduino, sensors, and other serial devices
- 🌐 HTTP API: RESTful API with JSON responses
- 🔒 Host-based Access Control: Configurable IP and port restrictions
- 📊 Comprehensive Logging: Detailed request logging
- 🔧 ABAP Integration: Ready-to-use ABAP client code
- 🧪 Test Mode: Mock data for development and testing
- ⚡ CORS Support: Cross-origin resource sharing enabled
Installation
pip install serialsrv
serialsrv --init
Quick Start
1. Basic Usage
# Copy ABAP files to current directory
serialsrv --abap
# Initialize/creating configuration file
serialsrv --init
# Start the server (default: localhost:7373)
serialsrv
# Start with custom host and port
serialsrv --host 0.0.0.0 --port 8080
# Run in test mode (returns mock data)
serialsrv --test
2. Configuration
Method 1: Using --init parameter (Recommended)
# Create configuration file in current directory
serialsrv --init
# This will create serialsrv.json with default settings
# You can then edit it to customize your configuration
Method 2: Manual creation
Create a serialsrv.json configuration file:
{
"allowed_hosts": [
{
"ip": "127.0.0.1",
"ports": [7373, 8080],
"description": "Localhost access"
},
{
"ip": "192.168.1.100",
"ports": [7373],
"description": "Local network access"
}
],
"serial": {
"port": "/dev/ttyUSB0",
"baudrate": 9600,
"timeout": 1,
"description": "Arduino connection"
},
"settings": {
"log_file": "requests.log",
"deny_unknown_hosts": true,
"log_all_requests": true
}
}
3. API Usage
GET Request
curl http://localhost:7373/
POST Request
curl -X POST http://localhost:7373/ \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
Response Format
{
"message": {
"value": 25.5,
"msg": "Temperature reading",
"mode": "read",
"result": "OK"
},
"timestamp": "2025-01-26T10:30:45.123456",
"method": "GET",
"path": "/",
"client_ip": "127.0.0.1",
"client_port": 54321
}
ABAP Integration
The package includes ready-to-use ABAP client code in the abap/ directory.
ABAP Client Features
- ✅ HTTP client integration
- ✅ JSON parsing with
/ui2/cl_json - ✅ Network connectivity testing
- ✅ Multiple connection options
- ✅ Detailed error handling
- ✅ Debug mode with system information
- ✅ Response headers analysis
Using ABAP Client
Method 1: Using --abap parameter (Recommended)
# Copy ABAP files to current directory
serialsrv --abap
# This will copy zakir_serial_test.abap to your current directory
# You can then copy it to your SAP system
Method 2: Manual extraction
- Copy the ABAP code from
serialsrv/abap/zakir_serial_test.abap - Create a new ABAP program in SAP system
- Paste the code and configure parameters
- Run the program to test connectivity
ABAP Program Parameters
- Host: Server hostname (default: localhost)
- Port: Server port (default: 7373)
- Test Options: Multiple connection testing
- Debug Mode: System information and network diagnostics
Configuration Options
Serial Configuration
{
"serial": {
"port": "/dev/ttyUSB0", // Serial port path
"baudrate": 9600, // Communication speed
"timeout": 1, // Read timeout in seconds
"description": "Arduino" // Optional description
}
}
Host Access Control
{
"allowed_hosts": [
{
"ip": "127.0.0.1", // Client IP address
"ports": [7373, 8080], // Allowed ports
"description": "Local" // Optional description
}
]
}
Settings
{
"settings": {
"log_file": "requests.log", // Log file path
"deny_unknown_hosts": true, // Block unauthorized hosts
"log_all_requests": true // Log all requests
}
}
Command Line Options
serialsrv [OPTIONS]
Options:
--host HOST Host to bind to (default: localhost)
--port PORT Port to listen on (default: 7373)
--test Run in test mode (returns mock data)
--abap Copy ABAP files to current directory and exit
--init Initialize serialsrv.json configuration file and exit
--help Show help message
Use Cases
IoT Data Collection
- Read sensor data from Arduino/Raspberry Pi
- Provide real-time data via HTTP API
- Integrate with monitoring systems
Industrial Automation
- Connect to PLCs and industrial devices
- Provide data to SCADA systems
- Enable remote monitoring
SAP Integration
- Bridge between serial devices and SAP systems
- Real-time data integration
- Automated data collection
Development
Project Structure
serialsrv/
├── __init__.py # Main server code
├── abap/ # ABAP client code
│ └── zakir_serial_test.abap
├── serialsrv.json # Configuration template
└── requirements.txt # Dependencies
Dependencies
pyserial>=3.5- Serial port communicationrequests>=2.25.0- HTTP client (for testing)
Troubleshooting
Common Issues
-
Port Already in Use
# Use different port serialsrv --port 8080
-
Serial Port Access Denied
# Add user to dialout group (Linux) sudo usermod -a -G dialout $USER
-
ABAP Connection Failed
- Check if Python service is running
- Verify network connectivity
- Check firewall settings
- Use debug mode in ABAP program
Log Analysis
Check the log file for detailed request information:
tail -f requests.log
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- 📧 Email: altay.kirecci@gmail.com
- https://www.opriori.com
- 🐛 Issues: GitHub Issues
- 📖 Documentation: GitHub Wiki
Changelog
v1.0.0
- Initial release
- Serial port reading functionality
- HTTP API with JSON responses
- Host-based access control
- ABAP integration support
- Comprehensive logging
- Test mode support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serialsrv-1.0.0.tar.gz.
File metadata
- Download URL: serialsrv-1.0.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4866d26c6fb4b3dc9980d59172fd7564cfa1eb3c9ed135fd9c734516219223c
|
|
| MD5 |
85c1dfe5d21a020d67be79c80e2416ce
|
|
| BLAKE2b-256 |
765c349e020ffcc1608f4f38a7fc91733ca14e3f2250eedc8e82fdec9a3a186b
|
File details
Details for the file serialsrv-1.0.0-py3-none-any.whl.
File metadata
- Download URL: serialsrv-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de108eef420c75345a615d42d5876e53c7311e24d60edb17de11298bef297677
|
|
| MD5 |
e92ef107c72265a9f90aeaadd3b002d9
|
|
| BLAKE2b-256 |
2848be26b609ed583a6ed4bb0763f9c4fd0fd5c1a075ba2077f52bd5628185ad
|