Skip to content

Commit 8dcd5d8

Browse files
authored
Merge pull request #37 from Three-Byte/update-readmes
Update project documentation and add MIT license.
2 parents aa11541 + b60f5a1 commit 8dcd5d8

6 files changed

Lines changed: 175 additions & 95 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Three Byte
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 150 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,180 @@
1-
# Network Communication Library
1+
# 🔗 ThreeByte.LinkLib
22

3-
## Overview
4-
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. /
3+
**A family of .NET communication libraries for TCP, UDP, Serial, projector control (PJLink), and networked power management (NetBooter).**
54

6-
## Features
7-
- **TCP Communication**: Establish and manage TCP connections for reliable data transfer.
8-
- **UDP Communication**: Send and receive data using the UDP protocol for low-latency communication.
9-
- **Serial Communication**: Interface with serial devices for data exchange.
10-
- **Asynchronous Support**: Fully supports asynchronous operations for non-blocking communication.
11-
- **Cross-Platform**: Compatible with .NET Standard 2.1, making it usable across different platforms.
5+
[![.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)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7+
[![NuGet](https://img.shields.io/badge/NuGet-published-blue?logo=nuget)](https://www.nuget.org/profiles/olaaf)
128

9+
---
1310

11+
## 📦 Packages
12+
13+
| Package | NuGet | Description |
14+
|---------|-------|-------------|
15+
| 🌐 [**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 |
16+
| 📡 [**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 |
17+
| 🔌 [**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 |
18+
| 🎬 [**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 |
19+
| 🔋 [**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 |
20+
| 🧩 [**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) |
21+
22+
---
23+
24+
## ✨ Features
25+
26+
- **Asynchronous** — Non-blocking I/O across all transport layers
27+
- **Thread-Safe** — Lock-protected operations for concurrent access
28+
- **Message Queuing** — FIFO queues (up to 100 messages) for reliable retrieval
29+
- **Event-Driven** — Rich events for connection changes, data arrival, and errors
30+
- **Auto-Reconnect** — TCP and Serial links recover automatically from failures
31+
- **Cross-Platform** — Targets .NET 10.0, .NET Standard 2.0, and .NET Standard 2.1
32+
33+
---
34+
35+
## 📥 Installation
36+
37+
Install only the packages you need:
1438

15-
## Installation
16-
To install the library, use the following command in the NuGet Package Manager Console:
1739
```powershell
18-
Install-Package ThreeByte.LinkLib.TcpLink
19-
Install-Package ThreeByte.LinkLib.UdpLink
20-
Install-Package ThreeByte.LinkLib.SerialLink
40+
dotnet add package ThreeByte.LinkLib.TcpLink
41+
dotnet add package ThreeByte.LinkLib.UdpLink
42+
dotnet add package ThreeByte.LinkLib.SerialLink
43+
dotnet add package ThreeByte.LinkLib.ProjectorLink
44+
dotnet add package ThreeByte.LinkLib.NetBooter
2145
```
2246

23-
## Usage
47+
---
48+
49+
## 🚀 Quick Start
50+
51+
### TCP — Connect to a device
2452

25-
### TCP Communication
2653
```csharp
2754
using ThreeByte.LinkLib.TcpLink;
28-
using System;
29-
using System.Threading.Tasks;
30-
31-
class Program
32-
{
33-
static async Task Main(string[] args)
34-
{
35-
var server = new TcpServer("0.0.0.0", 8080);
36-
server.Start();
37-
while (true)
38-
{
39-
var clientSocket = await server.AcceptConnectionAsync();
40-
var data = await server.ReceiveDataAsync(clientSocket);
41-
Console.WriteLine("Received: " + data);
42-
await server.SendDataAsync(clientSocket, "Hello, Client!");
43-
server.CloseConnection(clientSocket);
44-
}
45-
server.Stop();
46-
}
47-
}
55+
56+
var tcp = new AsyncTcpLink("192.168.1.100", 5000);
57+
tcp.DataReceived += (s, e) => Console.WriteLine($"Got {tcp.GetMessage()?.Length} bytes");
58+
59+
byte[] cmd = System.Text.Encoding.ASCII.GetBytes("HELLO\r\n");
60+
tcp.SendMessage(cmd);
4861
```
4962

50-
### UDP Communication
63+
### UDP — Fire-and-forget datagrams
64+
5165
```csharp
5266
using ThreeByte.LinkLib.UdpLink;
53-
using System;
54-
using System.Threading.Tasks;
55-
56-
class Program
57-
{
58-
static async Task Main(string[] args)
59-
{
60-
var client = new UdpClient("127.0.0.1", 8080);
61-
await client.SendDataAsync("Hello, Server!");
62-
var response = await client.ReceiveDataAsync();
63-
Console.WriteLine("Server response: " + response);
64-
}
65-
}
67+
68+
var udp = new AsyncUdpLink("192.168.1.50", remotePort: 9000, localPort: 9001);
69+
udp.SendMessage(System.Text.Encoding.ASCII.GetBytes("PING"));
6670
```
6771

68-
### Serial Communication
72+
### Serial — Talk to RS-232 devices
73+
6974
```csharp
7075
using ThreeByte.LinkLib.SerialLink;
71-
using System;
72-
using System.Threading.Tasks;
73-
74-
class Program
75-
{
76-
static async Task Main(string[] args)
77-
{
78-
var serial = new SerialComm("/dev/ttyUSB0", 9600);
79-
await serial.OpenAsync();
80-
await serial.SendDataAsync("Hello, Device!");
81-
var response = await serial.ReceiveDataAsync();
82-
Console.WriteLine("Device response: " + response);
83-
serial.Close();
84-
}
85-
}
76+
77+
var serial = new SerialLink("COM3", baudRate: 9600);
78+
serial.SendData(new byte[] { 0x01, 0x02, 0x03 });
79+
```
80+
81+
### Projector — PJLink power control
82+
83+
```csharp
84+
using ThreeByte.LinkLib.ProjectorLink;
85+
86+
using var projector = new Projector("192.168.1.200");
87+
projector.TurnOn();
88+
PowerStatus status = projector.GetState();
89+
string info = projector.GetInfo(); // "Epson EB-L1755U (Main Hall)"
90+
```
91+
92+
### NetBooter — Remote power outlet control
93+
94+
```csharp
95+
using ThreeByte.LinkLib.NetBooter;
96+
97+
var netBooter = new NetBooterLink("192.168.1.10");
98+
netBooter.Power(outlet: 1, state: true); // Turn on outlet 1
99+
netBooter.PollState();
100+
bool isOn = netBooter[1]; // Check outlet state
101+
```
102+
103+
---
104+
105+
## 🏗️ Architecture
106+
107+
```mermaid
108+
graph TD
109+
App["🖥️ Your Application"]
110+
111+
App --> TCP["🌐 TcpLink<br/><i>Async TCP Client</i>"]
112+
App --> UDP["📡 UdpLink<br/><i>Async UDP Client</i>"]
113+
App --> Serial["🔌 SerialLink<br/><i>RS-232 Communication</i>"]
114+
App --> Projector["🎬 ProjectorLink<br/><i>PJLink Protocol</i>"]
115+
App --> NetBooter["🔋 NetBooter<br/><i>HTTP Power Control</i>"]
116+
117+
TCP --> Shared["🧩 Shared<br/><i>LogFactory · Logging</i>"]
118+
UDP --> Shared
119+
Serial --> Shared
120+
Projector --> Shared
121+
NetBooter --> Shared
122+
123+
style App fill:#4a90d9,stroke:#2c5f8a,color:#fff
124+
style TCP fill:#6c5ce7,stroke:#4a3db5,color:#fff
125+
style UDP fill:#6c5ce7,stroke:#4a3db5,color:#fff
126+
style Serial fill:#6c5ce7,stroke:#4a3db5,color:#fff
127+
style Projector fill:#e17055,stroke:#b5553f,color:#fff
128+
style NetBooter fill:#e17055,stroke:#b5553f,color:#fff
129+
style Shared fill:#00b894,stroke:#009472,color:#fff
86130
```
87131

88-
## How to Build and Publish NuGet Packages using pipelines
132+
---
89133

90-
To build and publish NuGet packages, follow these steps:
91-
1. Create a new GitHub branch and switch to it
92-
2. Update the source code in any of the following `ThreeByte.LinkLib` folders:
93-
- ThreeByte.LinkLib.SerialLink
94-
- ThreeByte.LinkLib.TcpLink
95-
- ThreeByte.LinkLib.UdpLink
134+
## 📋 How to Build and Publish NuGet Packages
96135

97-
**Note:** The pipeline will only be triggered when changes are made in these folders
136+
1. Create a new branch and make your changes in any `ThreeByte.LinkLib.*` folder
137+
2. Commit and push to GitHub
138+
3. Create a pull request to `main` and attach a label:
139+
- `major` — breaking changes
140+
- `minor` — new features
141+
- `patch` — bug fixes
98142

99-
3. Commit and push your changes to the GitHub repository.
100-
4. Create a pull request to the main branch and attach one of the following labels based on the type of change you made:
101-
- major
102-
- minor
103-
- patch
143+
> We follow [Semantic Versioning](https://semver.org/)
104144
105-
**Note:** The version of the new NuGet package is determined by the attached label. We follow [Semantic Versioning](https://semver.org/)
145+
4. Merge your pull request
146+
5. Your NuGet package will be available on [nuget.org](https://www.nuget.org/profiles/olaaf) within ~5 minutes
106147

107-
5. Merge your pull request
108-
6. Wait approximately 5 minutes — your NuGet package will then be available on [nuget.org](https://www.nuget.org/profiles/olaaf)
148+
---
149+
150+
## 🤝 Contributing
109151

110-
## Contributing
111152
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
112153

113-
## License
114-
...
154+
---
115155

116-
## Contact
117-
For any questions or issues, please contact us at `support@mail`.
118-
```
119-
Feel free to customize this example to better fit your specific library and its features!
120-
If you have any other questions or need further assistance, let me know.
121-
```
156+
## 📄 License
157+
158+
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
159+
160+
MIT License
161+
162+
Copyright (c) 2025 Three Byte
163+
164+
Permission is hereby granted, free of charge, to any person obtaining a copy
165+
of this software and associated documentation files (the "Software"), to deal
166+
in the Software without restriction, including without limitation the rights
167+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
168+
copies of the Software, and to permit persons to whom the Software is
169+
furnished to do so, subject to the following conditions:
170+
171+
The above copyright notice and this permission notice shall be included in all
172+
copies or substantial portions of the Software.
173+
174+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
177+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
178+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
179+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
180+
SOFTWARE.

ThreeByte.LinkLib/ThreeByte.LinkLib.ProjectorLink/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@ This library implements the [PJLink](https://pjlink.jbmia.or.jp/english/) Class
205205

206206
## 📄 License
207207

208-
Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries.
208+
Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.

ThreeByte.LinkLib/ThreeByte.LinkLib.SerialLink/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,4 @@ var serial = new SerialLink(settings);
245245

246246
## 📄 License
247247

248-
Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries.
248+
Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.

ThreeByte.LinkLib/ThreeByte.LinkLib.Shared/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ warn: MyApp.DeviceController[0]
121121

122122
## 📄 License
123123

124-
Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries.
124+
Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.

ThreeByte.LinkLib/ThreeByte.LinkLib.TcpLink/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@ var settings = new TcpLinkSettings("192.168.1.100", 5000);
161161

162162
## 📄 License
163163

164-
Part of the [ThreeByte.LinkLib](https://github.com/olaafrossi/three-byte.link-lib) family of communication libraries.
164+
Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.

0 commit comments

Comments
 (0)