From b60f5a1678bf5a8b22983f2447f5f5ab4db99387 Mon Sep 17 00:00:00 2001 From: Olaaf Rossi Date: Wed, 25 Mar 2026 12:50:42 +0700 Subject: [PATCH] Update project documentation and add MIT license. - Rewrites the root README with a project overview, feature list, and quick-start examples for all packages. - Adds the MIT license file. - Updates repository URLs across sub-project READMEs to point to the Three-Byte organization. --- LICENSE | 21 ++ README.md | 241 +++++++++++------- .../ThreeByte.LinkLib.ProjectorLink/README.md | 2 +- .../ThreeByte.LinkLib.SerialLink/README.md | 2 +- .../ThreeByte.LinkLib.Shared/README.md | 2 +- .../ThreeByte.LinkLib.TcpLink/README.md | 2 +- 6 files changed, 175 insertions(+), 95 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a961b6c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Three Byte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f61ccc0..302a62c 100644 --- a/README.md +++ b/README.md @@ -1,121 +1,180 @@ -# Network Communication Library +# ๐Ÿ”— ThreeByte.LinkLib -## Overview -The Network Communication Library provides a simple and efficient way to handle network communication using TCP, UDP, and Serial protocols. This library is designed to be easy to use and integrate into your projects, offering robust and reliable communication capabilities. / +**A family of .NET communication libraries for TCP, UDP, Serial, projector control (PJLink), and networked power management (NetBooter).** -## Features -- **TCP Communication**: Establish and manage TCP connections for reliable data transfer. -- **UDP Communication**: Send and receive data using the UDP protocol for low-latency communication. -- **Serial Communication**: Interface with serial devices for data exchange. -- **Asynchronous Support**: Fully supports asynchronous operations for non-blocking communication. -- **Cross-Platform**: Compatible with .NET Standard 2.1, making it usable across different platforms. +[![.NET](https://img.shields.io/badge/.NET-10.0%20%7C%20Standard%202.0%20%7C%20Standard%202.1-purple?logo=dotnet)](https://dotnet.microsoft.com) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) +[![NuGet](https://img.shields.io/badge/NuGet-published-blue?logo=nuget)](https://www.nuget.org/profiles/olaaf) +--- +## ๐Ÿ“ฆ Packages + +| Package | NuGet | Description | +|---------|-------|-------------| +| ๐ŸŒ [**TcpLink**](ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.TcpLink?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.TcpLink) | Async TCP client with auto-reconnect and message queuing | +| ๐Ÿ“ก [**UdpLink**](ThreeByte.LinkLib/ThreeByte.LinkLib.UdpLink/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.UdpLink?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.UdpLink) | Async UDP client with configurable local/remote endpoints | +| ๐Ÿ”Œ [**SerialLink**](ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.SerialLink?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.SerialLink) | RS-232 serial communication with optional frame-based protocol | +| ๐ŸŽฌ [**ProjectorLink**](ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.ProjectorLink?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.ProjectorLink) | PJLink protocol client for projector power control and queries | +| ๐Ÿ”‹ [**NetBooter**](ThreeByte.LinkLib/ThreeByte.LinkLib.NetBooter/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.NetBooter?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.NetBooter) | Synaccess NetBooter networked power outlet controller | +| ๐Ÿงฉ [**Shared**](ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/) | [![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.Shared?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.Shared) | Shared logging infrastructure (auto-included as dependency) | + +--- + +## โœจ Features + +- **Asynchronous** โ€” Non-blocking I/O across all transport layers +- **Thread-Safe** โ€” Lock-protected operations for concurrent access +- **Message Queuing** โ€” FIFO queues (up to 100 messages) for reliable retrieval +- **Event-Driven** โ€” Rich events for connection changes, data arrival, and errors +- **Auto-Reconnect** โ€” TCP and Serial links recover automatically from failures +- **Cross-Platform** โ€” Targets .NET 10.0, .NET Standard 2.0, and .NET Standard 2.1 + +--- + +## ๐Ÿ“ฅ Installation + +Install only the packages you need: -## Installation -To install the library, use the following command in the NuGet Package Manager Console: ```powershell -Install-Package ThreeByte.LinkLib.TcpLink -Install-Package ThreeByte.LinkLib.UdpLink -Install-Package ThreeByte.LinkLib.SerialLink +dotnet add package ThreeByte.LinkLib.TcpLink +dotnet add package ThreeByte.LinkLib.UdpLink +dotnet add package ThreeByte.LinkLib.SerialLink +dotnet add package ThreeByte.LinkLib.ProjectorLink +dotnet add package ThreeByte.LinkLib.NetBooter ``` -## Usage +--- + +## ๐Ÿš€ Quick Start + +### TCP โ€” Connect to a device -### TCP Communication ```csharp using ThreeByte.LinkLib.TcpLink; -using System; -using System.Threading.Tasks; - -class Program -{ - static async Task Main(string[] args) - { - var server = new TcpServer("0.0.0.0", 8080); - server.Start(); - while (true) - { - var clientSocket = await server.AcceptConnectionAsync(); - var data = await server.ReceiveDataAsync(clientSocket); - Console.WriteLine("Received: " + data); - await server.SendDataAsync(clientSocket, "Hello, Client!"); - server.CloseConnection(clientSocket); - } - server.Stop(); - } -} + +var tcp = new AsyncTcpLink("192.168.1.100", 5000); +tcp.DataReceived += (s, e) => Console.WriteLine($"Got {tcp.GetMessage()?.Length} bytes"); + +byte[] cmd = System.Text.Encoding.ASCII.GetBytes("HELLO\r\n"); +tcp.SendMessage(cmd); ``` -### UDP Communication +### UDP โ€” Fire-and-forget datagrams + ```csharp using ThreeByte.LinkLib.UdpLink; -using System; -using System.Threading.Tasks; - -class Program -{ - static async Task Main(string[] args) - { - var client = new UdpClient("127.0.0.1", 8080); - await client.SendDataAsync("Hello, Server!"); - var response = await client.ReceiveDataAsync(); - Console.WriteLine("Server response: " + response); - } -} + +var udp = new AsyncUdpLink("192.168.1.50", remotePort: 9000, localPort: 9001); +udp.SendMessage(System.Text.Encoding.ASCII.GetBytes("PING")); ``` -### Serial Communication +### Serial โ€” Talk to RS-232 devices + ```csharp using ThreeByte.LinkLib.SerialLink; -using System; -using System.Threading.Tasks; - -class Program -{ - static async Task Main(string[] args) - { - var serial = new SerialComm("/dev/ttyUSB0", 9600); - await serial.OpenAsync(); - await serial.SendDataAsync("Hello, Device!"); - var response = await serial.ReceiveDataAsync(); - Console.WriteLine("Device response: " + response); - serial.Close(); - } -} + +var serial = new SerialLink("COM3", baudRate: 9600); +serial.SendData(new byte[] { 0x01, 0x02, 0x03 }); +``` + +### Projector โ€” PJLink power control + +```csharp +using ThreeByte.LinkLib.ProjectorLink; + +using var projector = new Projector("192.168.1.200"); +projector.TurnOn(); +PowerStatus status = projector.GetState(); +string info = projector.GetInfo(); // "Epson EB-L1755U (Main Hall)" +``` + +### NetBooter โ€” Remote power outlet control + +```csharp +using ThreeByte.LinkLib.NetBooter; + +var netBooter = new NetBooterLink("192.168.1.10"); +netBooter.Power(outlet: 1, state: true); // Turn on outlet 1 +netBooter.PollState(); +bool isOn = netBooter[1]; // Check outlet state +``` + +--- + +## ๐Ÿ—๏ธ Architecture + +```mermaid +graph TD + App["๐Ÿ–ฅ๏ธ Your Application"] + + App --> TCP["๐ŸŒ TcpLink
Async TCP Client"] + App --> UDP["๐Ÿ“ก UdpLink
Async UDP Client"] + App --> Serial["๐Ÿ”Œ SerialLink
RS-232 Communication"] + App --> Projector["๐ŸŽฌ ProjectorLink
PJLink Protocol"] + App --> NetBooter["๐Ÿ”‹ NetBooter
HTTP Power Control"] + + TCP --> Shared["๐Ÿงฉ Shared
LogFactory ยท Logging"] + UDP --> Shared + Serial --> Shared + Projector --> Shared + NetBooter --> Shared + + style App fill:#4a90d9,stroke:#2c5f8a,color:#fff + style TCP fill:#6c5ce7,stroke:#4a3db5,color:#fff + style UDP fill:#6c5ce7,stroke:#4a3db5,color:#fff + style Serial fill:#6c5ce7,stroke:#4a3db5,color:#fff + style Projector fill:#e17055,stroke:#b5553f,color:#fff + style NetBooter fill:#e17055,stroke:#b5553f,color:#fff + style Shared fill:#00b894,stroke:#009472,color:#fff ``` -## How to Build and Publish NuGet Packages using pipelines +--- -To build and publish NuGet packages, follow these steps: -1. Create a new GitHub branch and switch to it -2. Update the source code in any of the following `ThreeByte.LinkLib` folders: -- ThreeByte.LinkLib.SerialLink -- ThreeByte.LinkLib.TcpLink -- ThreeByte.LinkLib.UdpLink +## ๐Ÿ“‹ How to Build and Publish NuGet Packages -**Note:** The pipeline will only be triggered when changes are made in these folders +1. Create a new branch and make your changes in any `ThreeByte.LinkLib.*` folder +2. Commit and push to GitHub +3. Create a pull request to `main` and attach a label: + - `major` โ€” breaking changes + - `minor` โ€” new features + - `patch` โ€” bug fixes -3. Commit and push your changes to the GitHub repository. -4. Create a pull request to the main branch and attach one of the following labels based on the type of change you made: -- major -- minor -- patch + > We follow [Semantic Versioning](https://semver.org/) -**Note:** The version of the new NuGet package is determined by the attached label. We follow [Semantic Versioning](https://semver.org/) +4. Merge your pull request +5. Your NuGet package will be available on [nuget.org](https://www.nuget.org/profiles/olaaf) within ~5 minutes -5. Merge your pull request -6. Wait approximately 5 minutes โ€” your NuGet package will then be available on [nuget.org](https://www.nuget.org/profiles/olaaf) +--- + +## ๐Ÿค Contributing -## Contributing Contributions are welcome! Please fork the repository and submit a pull request with your changes. -## License -... +--- -## Contact -For any questions or issues, please contact us at `support@mail`. -``` -Feel free to customize this example to better fit your specific library and its features! -If you have any other questions or need further assistance, let me know. -``` +## ๐Ÿ“„ License + +This project is licensed under the MIT License โ€” see the [LICENSE](LICENSE) file for details. + +MIT License + +Copyright (c) 2025 Three Byte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/README.md b/ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/README.md index 0ccc607..b62142a 100644 --- a/ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/README.md +++ b/ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/README.md @@ -205,4 +205,4 @@ This library implements the [PJLink](https://pjlink.jbmia.or.jp/english/) Class ## ๐Ÿ“„ License -Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries. +Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries. diff --git a/ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/README.md b/ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/README.md index 7b1e5f4..c81ad6d 100644 --- a/ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/README.md +++ b/ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/README.md @@ -245,4 +245,4 @@ var serial = new SerialLink(settings); ## ๐Ÿ“„ License -Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries. +Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries. diff --git a/ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/README.md b/ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/README.md index 5664e4b..48559bd 100644 --- a/ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/README.md +++ b/ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/README.md @@ -121,4 +121,4 @@ warn: MyApp.DeviceController[0] ## ๐Ÿ“„ License -Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries. +Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries. diff --git a/ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/README.md b/ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/README.md index 20e6582..7e81c40 100644 --- a/ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/README.md +++ b/ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/README.md @@ -161,4 +161,4 @@ var settings = new TcpLinkSettings("192.168.1.100", 5000); ## ๐Ÿ“„ License -Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries. +Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.