Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
BasedOnStyle: Google
IndentWidth: 2
ColumnLimit: 80
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Linux
IndentCaseLabels: false
PointerAlignment: Right
SpaceAfterCStyleCast: true
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{c,h}]
indent_style = space
indent_size = 2

[*.{md,txt}]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

[*.sh]
indent_style = space
indent_size = 2
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Initialize with '...'
2. Send packet with '...'
3. Observe '...'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**
- OS: [e.g. Ubuntu 20.04]
- Compiler: [e.g. GCC 9.3.0]
- Baud Rate: [e.g. 921600]
- Payload Size: [e.g. 512 bytes]

**Code Sample**
```c
// Minimal code to reproduce the issue
```

**Logs**
```
// Relevant log output
```

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature Request
about: Suggest an idea for this project
title: '[FEATURE] '
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* OS:
* Compiler:
* Baud Rate:

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
compiler: [gcc, clang]

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential

- name: Build with Make
run: |
make CC=${{ matrix.compiler }}

- name: Clean
run: make clean

- name: Build with CMake
run: |
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=${{ matrix.compiler }}
make
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Build artifacts
*.o
*.a
*.so
*.dylib
peera
peerb

# CMake
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile.cmake
*.cmake
!CMakeLists.txt

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Temporary files
/tmp/uart-mock-*
*.log
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2020-03-04

### Added
- Initial release of libUartCommProtocol
- TCP-like reliable transmission with ACK/NACK
- UDP-like unreliable transmission
- Full-duplex communication support
- CRC16 checksum for data integrity
- Automatic retransmission mechanism
- Low memory footprint (~1KB)
- Support for both big-endian and little-endian architectures
- Benchmark examples (peer_a and peer_b)
- POSIX/Linux platform support

### Performance
- TCP mode: 64 KB/s at 921600 bps (71% bandwidth utilization)
- UDP mode: 94 KB/s at 921600 bps (84.5% bandwidth utilization)
- Tested on RT-Thread RTOS

## [Unreleased]

### Planned
- Windows platform support
- Additional examples
- Unit tests
- Performance optimizations
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.10)
project(libUartCommProtocol VERSION 1.0.0 LANGUAGES C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Compiler flags
add_compile_options(-Wall -Werror -O2)

# Include directories
include_directories(inc utils)

# Core library sources
set(CORE_SOURCES
src/uni_communication.c
utils/uni_crc16.c
utils/uni_log.c
utils/uni_interruptable.c
)

# Create static library
add_library(uartcomm STATIC ${CORE_SOURCES})
target_link_libraries(uartcomm pthread)

# Examples
option(BUILD_EXAMPLES "Build example programs" ON)

if(BUILD_EXAMPLES)
add_executable(peera benchmark/peer_a.c)
target_link_libraries(peera uartcomm pthread)

add_executable(peerb benchmark/peer_b.c)
target_link_libraries(peerb uartcomm pthread)
endif()

# Installation
install(TARGETS uartcomm
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

install(FILES inc/uni_communication.h
DESTINATION include/uartcomm
)
72 changes: 72 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Contributing to libUartCommProtocol

Thank you for your interest in contributing! This document provides guidelines for contributing to this project.

## Getting Started

1. Fork the repository
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/libUartCommProtocol.git`
3. Create a feature branch: `git checkout -b feature/your-feature-name`

## Development Setup

### Prerequisites
- GCC compiler with C99 support
- pthread library
- Make or CMake

### Building
```bash
# Using Make
make

# Using CMake
mkdir build && cd build
cmake ..
make
```

## Code Style

- Follow the existing code style in the project
- Use 2 spaces for indentation
- Keep lines under 80 characters when possible
- Add comments for complex logic
- Use descriptive variable and function names

## Testing

Before submitting a pull request:

1. Build the project without warnings
2. Run the benchmark examples:
```bash
./peera &
./peerb
```
3. Verify no memory leaks (use valgrind if available)

## Submitting Changes

1. Commit your changes with clear, descriptive messages
2. Push to your fork
3. Submit a pull request to the main repository
4. Describe your changes and the problem they solve

## Reporting Issues

When reporting issues, please include:
- Operating system and version
- Compiler version
- Steps to reproduce the issue
- Expected vs actual behavior
- Any relevant logs or error messages

## License

By contributing, you agree that your contributions will be licensed under the GPL-2.0 License.

## Contact

- Email: junlon2006@163.com
- GitHub Issues: https://github.com/junlon2006/libUartCommProtocol/issues
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 2017-2020 Junlon2006

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

---

For the full text of the GNU General Public License version 2, see:
https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Loading