mirror of
https://github.com/ekinnee/SharpCAT.git
synced 2025-12-06 03:31:59 +01:00
|
|
||
|---|---|---|
| .. | ||
| Controllers | ||
| Models | ||
| Properties | ||
| Services | ||
| appsettings.Development.json | ||
| appsettings.json | ||
| Program.cs | ||
| README.md | ||
| Server.csproj | ||
| SharpCAT.Server.http | ||
SharpCAT Server
A cross-platform ASP.NET Core Web API server that provides REST endpoints for CAT (Computer Aided Transceiver) control using the SharpCAT library.
Features
- Cross-platform: Works on Windows, Linux, and macOS
- REST API: Clean, documented REST endpoints for radio control
- Serial Communication: Leverages the SharpCAT core library for serial port operations
- Swagger Documentation: Built-in API documentation and testing interface
- Error Handling: Comprehensive error handling and logging
API Endpoints
Serial Port Management
GET /api/cat/ports- List all available serial portsPOST /api/cat/open- Open and configure a serial portPOST /api/cat/close- Close the currently opened portGET /api/cat/status- Get current port connection status
CAT Commands
POST /api/cat/command- Send arbitrary CAT commands to the radio
Health Check
GET /health- Simple health check endpoint
Quick Start
Prerequisites
- .NET 8.0 SDK or later
Running the Server
-
Navigate to the server directory:
cd Server/SharpCAT.Server -
Build and run the server:
dotnet run -
The server will start and listen on
http://localhost:5188by default -
Open your browser to
http://localhost:5188to access the Swagger UI for interactive API documentation
Example Usage
List Available Ports
curl http://localhost:5188/api/cat/ports
Open a Serial Port
curl -X POST http://localhost:5188/api/cat/open \
-H "Content-Type: application/json" \
-d '{
"portName": "COM3",
"baudRate": 9600,
"parity": "None",
"stopBits": "One",
"handshake": "None"
}'
Send a CAT Command
curl -X POST http://localhost:5188/api/cat/command \
-H "Content-Type: application/json" \
-d '{"command": "FA;"}'
Check Status
curl http://localhost:5188/api/cat/status
Configuration
Port Configuration Options
When opening a port, you can configure:
- Port Name: Serial port name (e.g., "COM1" on Windows, "/dev/ttyUSB0" on Linux)
- Baud Rate: Communication speed (default: 9600)
- Parity: Error checking method (None, Odd, Even, Mark, Space)
- Stop Bits: Number of stop bits (None, One, Two, OnePointFive)
- Handshake: Flow control method (None, XOnXOff, RequestToSend, RequestToSendXOnXOff)
Logging
The server uses ASP.NET Core's built-in logging. Log levels can be configured in appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"SharpCAT.Server": "Debug"
}
}
}
Development
Building from Source
- Ensure you have the .NET 8.0 SDK installed
- Clone the repository
- Navigate to the project root
- Build the solution:
dotnet build
Project Structure
Server/SharpCAT.Server/
├── Controllers/
│ └── CatController.cs # Main API controller
├── Models/
│ └── ApiModels.cs # Request/response models
├── Services/
│ ├── ISerialCommunicationService.cs # Service interface
│ └── SerialCommunicationService.cs # Service implementation
├── Program.cs # Application entry point
└── SharpCAT.Server.csproj # Project file
Dependencies
- Microsoft.AspNetCore.OpenApi - OpenAPI support
- Swashbuckle.AspNetCore - Swagger documentation
- SharpCAT - Core CAT control library
License
This project follows the same license as the parent SharpCAT project.
Contributing
Contributions are welcome! Please follow the existing code style and add appropriate tests for new features.