Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
d027eb9
Update README.md
Mqxx May 23, 2023
ed93b3b
ci
Katze719 May 23, 2023
9cd158f
compiled binarys
github-actions[bot] May 24, 2023
949ded6
Merge branch 'github-CI' into dev
Katze719 May 24, 2023
21dbf2e
compiled binarys
github-actions[bot] May 24, 2023
ef59ff5
rename 'dls' to 'bin'
Katze719 May 24, 2023
3d429d7
fix missing bin folder
Katze719 May 24, 2023
e7a189e
compiled binarys
github-actions[bot] May 24, 2023
a3613fb
Update build.yml
Mqxx May 25, 2023
ed0b924
Update build.yml
Mqxx May 25, 2023
cfe3469
Commited compiled binaries
github-actions[bot] May 25, 2023
e25107b
i nned a commit msg
Katze719 May 25, 2023
7db1a0a
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Katze719 May 25, 2023
cd6183c
exclude include
Katze719 May 25, 2023
99a327a
Create CMakeLists.txt
Katze719 May 26, 2023
ef6aed5
Update CMakeLists.txt
Katze719 May 26, 2023
753b84e
Update CMakeLists.txt
Katze719 May 26, 2023
a76472e
Delete CMakeLists.txt
Katze719 May 26, 2023
f6c9b40
Create CMakeLists.txt
Katze719 May 26, 2023
dda0f26
Update CMakeLists.txt
Katze719 May 26, 2023
57e5ec6
Delete CMakeLists.txt
Katze719 May 26, 2023
62dbd7b
Update CMakeLists.txt
Katze719 May 26, 2023
dae652b
Create CMakeLists.txt
Katze719 May 26, 2023
fe3fc98
Update CMakeLists.txt
Katze719 May 26, 2023
3885abb
Update build.yml
Katze719 May 26, 2023
c836af5
Commited compiled binaries
github-actions[bot] May 26, 2023
ff520aa
Updating TypeScript files
Mqxx May 26, 2023
ea2a76a
Update register_serial_functions.ts
Mqxx May 26, 2023
d0f7492
Update Serial.ts
Mqxx May 26, 2023
bc67c2d
fix getAvailablePorts Windows
Katze719 May 27, 2023
1db2d05
Commited compiled binaries
github-actions[bot] May 27, 2023
1ccf022
Commited compiled binaries
github-actions[bot] May 27, 2023
4c02303
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Katze719 May 27, 2023
b5fa727
Commited compiled binaries
github-actions[bot] May 27, 2023
124b010
Update Serial.ts
Mqxx May 27, 2023
05cff6c
remove trailing comma
Katze719 May 27, 2023
5757efa
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Katze719 May 27, 2023
4c97f72
Commited compiled binaries
github-actions[bot] May 27, 2023
7dd8995
Update register_serial_functions.ts
Mqxx May 27, 2023
861f3ce
Update README.md
Mqxx May 27, 2023
4a08ec3
Update README.md
Mqxx May 27, 2023
a1056a6
cmake
Katze719 May 27, 2023
df18ea9
Delete baudrate.ts
Mqxx May 27, 2023
3059017
Create binary_extensions.ts
Mqxx May 27, 2023
7fc7186
Update Serial.ts
Mqxx May 27, 2023
d40f9a0
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Mqxx May 27, 2023
fe54876
cmake
Katze719 May 27, 2023
82205e6
Commited compiled binaries
github-actions[bot] May 27, 2023
9dbe4ba
Update mod.ts
Mqxx May 27, 2023
d7b25bf
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Mqxx May 27, 2023
c996474
Update binary_extensions.ts
Mqxx May 27, 2023
0cca986
Update load_binary_for_os.ts
Mqxx May 27, 2023
d8469c6
Update binary_extensions.ts
Mqxx May 27, 2023
22bbf9e
Update README.md
Mqxx May 27, 2023
940276c
Updated files
Mqxx May 28, 2023
de3113c
Update register_serial_functions.ts
Mqxx May 28, 2023
8029a9b
update
Katze719 May 28, 2023
7f10adb
compile
Katze719 May 28, 2023
94999ca
new error handling
Katze719 May 28, 2023
2a1c10e
new error handling
Katze719 May 28, 2023
6bf5ee0
d
Katze719 May 28, 2023
1fabbc5
linux error handling implementation
Katze719 May 28, 2023
93f155a
Commited compiled binaries
github-actions[bot] May 28, 2023
55f5365
typescript
Katze719 May 28, 2023
2fb812a
Update register_serial_functions.ts
Mqxx May 28, 2023
6c4e624
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Katze719 May 28, 2023
487e6dd
Update Serial.ts
Mqxx May 28, 2023
b2af4ed
Updated C++ code
Mqxx May 28, 2023
194cd95
Update register_serial_functions.ts
Mqxx May 28, 2023
9b71f5f
Update serial_unix.cpp
Mqxx May 28, 2023
be6b389
Update serial_unix.h
Mqxx May 28, 2023
92e4cb1
Update serial_windows.cpp
Mqxx May 28, 2023
4a20188
Commited compiled binaries
github-actions[bot] May 28, 2023
8dd6f0d
update windows.cpp
Katze719 May 28, 2023
6c0ffb4
Commited compiled binaries
github-actions[bot] May 28, 2023
35bdaf9
error handling
Katze719 May 28, 2023
075eb6b
Commited compiled binaries
github-actions[bot] May 28, 2023
3c32ae0
Update serial_functions.d.ts
Mqxx May 28, 2023
32bf81b
Update register_serial_functions.ts
Mqxx May 28, 2023
c6b1e3a
Update Serial.ts
Mqxx May 28, 2023
add67bb
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Mqxx May 28, 2023
9a929f4
added \0
Katze719 May 28, 2023
9fe94a1
Commited compiled binaries
github-actions[bot] May 28, 2023
064362e
error msg
Katze719 May 28, 2023
fad8283
Commited compiled binaries
github-actions[bot] May 28, 2023
b025375
removed callback error msg
Katze719 May 28, 2023
1cdf7a1
fix unix
Katze719 May 28, 2023
dd39966
Commited compiled binaries
github-actions[bot] May 28, 2023
185e9cd
changed namings in cpp code
Katze719 May 28, 2023
a9e5d66
naming
Katze719 May 28, 2023
b9ba589
Commited compiled binaries
github-actions[bot] May 28, 2023
e86761d
using more callbacks
Katze719 May 28, 2023
7866c2f
Commited compiled binaries
github-actions[bot] May 28, 2023
7da9239
updated ts
Katze719 May 28, 2023
005ddb7
get posts info fix
Katze719 May 28, 2023
b0c3cf0
Commited compiled binaries
github-actions[bot] May 28, 2023
8aece09
added returns
Katze719 May 28, 2023
3af54b3
fix
Katze719 May 28, 2023
7d4c67a
Commited compiled binaries
github-actions[bot] May 28, 2023
803ab98
test
Katze719 May 28, 2023
3a5c73b
Commited compiled binaries
github-actions[bot] May 28, 2023
6b1da12
fix
Katze719 May 28, 2023
be8c6fc
Commited compiled binaries
github-actions[bot] May 28, 2023
6e8646d
fix
Katze719 May 28, 2023
ffae7a4
Commited compiled binaries
github-actions[bot] May 28, 2023
6f34029
minimized cpp code
Katze719 May 29, 2023
f808a58
Commited compiled binaries
github-actions[bot] May 29, 2023
bdd6c47
fix
Katze719 May 29, 2023
d300f00
Commited compiled binaries
github-actions[bot] May 29, 2023
231d906
moved includes
Katze719 May 29, 2023
bdecc90
Commited compiled binaries
github-actions[bot] May 29, 2023
a1d4b36
Merge pull request #4 from TypeScriptPlayground/advance-cpp-code
Katze719 May 29, 2023
46cd1a7
Commited compiled binaries
github-actions[bot] May 29, 2023
5899135
Updated typescript files
Mqxx May 29, 2023
203342c
Update serial_windows.cpp
Mqxx May 29, 2023
3c86c0f
Commited compiled binaries
github-actions[bot] May 29, 2023
01487e5
Update serial_functions.d.ts
Mqxx May 29, 2023
8607867
Update serial.h
Mqxx May 29, 2023
f28bc5a
Update serial.h
Mqxx May 29, 2023
1b7595d
Update serial_unix.cpp
Mqxx May 29, 2023
c6e43bf
Update serial_windows.cpp
Mqxx May 29, 2023
ef5daa2
Merge branch 'dev' of https://github.com/TypeScriptPlayground/Serial …
Mqxx May 29, 2023
a4f8c14
Update serial_unix.cpp
Mqxx May 29, 2023
917352a
Commited compiled binaries
github-actions[bot] May 29, 2023
a9df452
Update serial.h
Mqxx May 29, 2023
1d4eee3
Update serial_windows.cpp
Mqxx May 29, 2023
9d7e77f
Commited compiled binaries
github-actions[bot] May 29, 2023
0f312e7
Update register_serial_functions.ts
Mqxx May 29, 2023
925dbb6
Update Serial.ts
Mqxx May 29, 2023
72b94aa
Co-authored-by: Mqx <Mqxx@users.noreply.github.com>
Katze719 May 29, 2023
f4997af
Commited compiled binaries
github-actions[bot] May 29, 2023
bbce86d
fix
Katze719 May 29, 2023
29e89ca
Commited compiled binaries
github-actions[bot] May 29, 2023
bee57fc
fix
Katze719 May 29, 2023
936ac5f
Commited compiled binaries
github-actions[bot] May 29, 2023
2c3c75e
fix
Katze719 May 29, 2023
1130e27
Commited compiled binaries
github-actions[bot] May 29, 2023
824ad47
fix
Katze719 May 29, 2023
4f97208
Commited compiled binaries
github-actions[bot] May 29, 2023
ee77ddc
fix
Katze719 May 29, 2023
33c194e
Commited compiled binaries
github-actions[bot] May 29, 2023
93438a3
fix
Katze719 May 29, 2023
e12c6f3
Commited compiled binaries
github-actions[bot] May 29, 2023
5e12241
Co-authored-by: Mqx <Mqxx@users.noreply.github.com>
Katze719 May 29, 2023
fbb0ef2
Commited compiled binaries
github-actions[bot] May 29, 2023
89e401f
linux fix
Katze719 May 29, 2023
a7c77a9
Commited compiled binaries
github-actions[bot] May 29, 2023
86f4725
Update README.md
Mqxx May 29, 2023
e0739c1
Update README.md
Mqxx May 29, 2023
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
92 changes: 92 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build Binarys

on:
push:
paths:
- 'src/**'
- '.github/workflows/build.yml'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build_linux:
name: Build linux binaries
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux-binary
path: ${{github.workspace}}/build/src/libserialport.so

build_windows:
name: Build win64 binaries
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: windows-binary
path: ${{github.workspace}}\build\src\Release\serialport.dll

commit:
needs: [build_windows, build_linux]
name: Commit binaries
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Download artifact
uses: actions/download-artifact@v3
with:
path: ${{github.workspace}}/tmp

- name: Create bin folder if it does not exist
run: mkdir -p ${{github.workspace}}/lib/bin

- name: Move and rename linux binary
run: mv ${{github.workspace}}/tmp/linux-binary/libserialport.so ${{github.workspace}}/lib/bin/linux.so

- name: Move and rename windows binary
run: mv ${{github.workspace}}/tmp/windows-binary/serialport.dll ${{github.workspace}}/lib/bin/windows.dll

- name: Configure Git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Commit binaries
run: |
git add ${{github.workspace}}/lib/bin/*
git diff-index --quiet HEAD || git commit -m "Commited compiled binaries"

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.RELEASE_TOKEN }}
branch: ${{ github.ref }}

48 changes: 0 additions & 48 deletions .github/workflows/build_linux.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/build_windows.yml

This file was deleted.

20 changes: 7 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
name: "Pre-Release"

on:
push:
branches: [ "main" ]
paths:
- 'include/**'
- 'src/**'
- '.github/workflows/release.yml'
pull_request:
branches: [ "main" ]
paths:
- 'include/**'
- 'src/**'
- '.github/workflows/release.yml'

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand Down Expand Up @@ -69,18 +63,18 @@ jobs:
path: ${{github.workspace}}/tmp

- name: Rename linux Binary
run: mv ${{github.workspace}}/tmp/linux-binary/libserialport.so ${{github.workspace}}/lib/dls/linux.so
run: mv ${{github.workspace}}/tmp/linux-binary/libserialport.so ${{github.workspace}}/lib/bin/linux.so

- name: Rename windows Binary
run: mv ${{github.workspace}}/tmp/windows-binary/serialport.dll ${{github.workspace}}/lib/dls/windows.dll
run: mv ${{github.workspace}}/tmp/windows-binary/serialport.dll ${{github.workspace}}/lib/bin/windows.dll

- run: cd ${{github.workspace}}

- name: make .tar.gz file
run: tar -czvf lib.tar.gz ./lib
run: tar -czvf SerialLink-lib.tar.gz ./lib

- name: make .zip
run: zip -r lib.zip ./lib
run: zip -r SerialLink-lib.zip ./lib

- uses: "marvinpinto/action-automatic-releases@latest"
with:
Expand All @@ -89,5 +83,5 @@ jobs:
prerelease: true
title: "Development Build"
files: |
lib.tar.gz
lib.zip
SerialLink-lib.tar.gz
SerialLink-lib.zip
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#directories
.vscode/
.cache/
.github/
build/
test/
39 changes: 2 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.22)

set(PROJECT_N serialport)
project(${PROJECT_N} VERSION 1.0)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(LIB true)

file(GLOB_RECURSE SRCS ${PROJECT_SOURCE_DIR}/src/*.cpp)

# a macro that gets all of the header containing directories.
MACRO(header_directories return_list includes_base_folder extention )
FILE(GLOB_RECURSE new_list ${includes_base_folder}/*.${extention})
SET(dir_list "")
FOREACH(file_path ${new_list})
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
SET(dir_list ${dir_list} ${dir_path})
ENDFOREACH()
LIST(REMOVE_DUPLICATES dir_list)
SET(${return_list} ${dir_list})
ENDMACRO()

# using said macro.
header_directories(INCLUDES ${PROJECT_SOURCE_DIR}/include/ hpp)

message("src files:")
foreach(file ${SRCS})
message(STATUS ${file})
endforeach()

message("include directories:")
foreach(dir ${INCLUDES})
message(STATUS ${dir})
endforeach()

if(LIB)
add_library(${PROJECT_N} SHARED ${SRCS})
else()
add_executable(${PROJECT_N} ${SRCS})
endif(LIB)
add_subdirectory(src)

target_include_directories(${PROJECT_N} PUBLIC include)

# set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-shared -fPIC -Wall")
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<!-- Badges -->
[Build Win32 DLL]: https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_windows.yml?label=Build%20Win32%20DLL&labelColor=343b42&logo=github&logoColor=959DA5 'Win32 Build'
[Build Linux SO]: https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_linux.yml?label=Build%20Linux%20SO&labelColor=343b42&logo=github&logoColor=959DA5 'Linux Build'
[Build binaries]: https://img.shields.io/github/actions/workflow/status/TypeScriptPlayground/Serial/build_windows.yml?label=Build%20binaries&labelColor=343b42&logo=github&logoColor=959DA5 'Build binaries'
[Release Downloads]: https://img.shields.io/github/downloads/TypeScriptPlayground/Serial/total?label=Downloads%20&labelColor=343b42&logo=docusign&logoColor=959DA5 'Total Release Downloads'

# Serial
[![Build Win32 DLL]](https://github.com/TypeScriptPlayground/Serial/actions/workflows/build_windows.yml)
[![Build Linux SO]](https://github.com/TypeScriptPlayground/Serial/actions/workflows/build_linux.yml)
[![Build binaries]](https://github.com/TypeScriptPlayground/Serial/actions/workflows/build.yml)
[![Release Downloads]](https://github.com/TypeScriptPlayground/Serial/releases)

<a href="https://deno.land"><img align="right" src="https://deno.land/logo.svg" height="150px" alt="the deno mascot dinosaur standing in the rain"></a>
Expand Down Expand Up @@ -33,10 +31,10 @@ This library provides an interface for the communication with serial devices and
- Works on different operating systems (check [compatibility](#compatibility) for mor info).

## Compatibility
| OS | Tested version | Current state |
|---------|------------------|---------------|
| Windows | Windows 10 (x64) | implemented |
| Linux | - | in progress |
| OS | Tested version | Current state |
|---------|-------------------------|---------------|
| Windows | Windows 10 (x64) | implemented |
| Linux | Ubuntu Server 22.04 LTS | implemented |

## Possible/Known issues
- What happens if you open multiple connections from the same instance.
Expand All @@ -45,6 +43,10 @@ This library provides an interface for the communication with serial devices and
- Linux write currently not working

## Examples - How to use
To use this library you need the following flags to run it:
- `--unstable`
- `--allow-ffi`

### Ports
Get a list with all serial ports and their info that are currently available on your system.

Expand Down Expand Up @@ -77,17 +79,17 @@ Send data to a serial device. For exampe to an [Arduino](https://www.arduino.cc/

`main.ts`
```typescript
import { Serial } from "./mod.ts";
import { Serial, baudrate } from "./mod.ts";

// create new instance of a serial object
const serial = new Serial();

// open the connection
serial.open();
serial.open('COM1', baudrate.B9600);

// encode the message to a Uint8Array
const textToSend = 'Hello from TypeScript!'
const encodedTextToSend = new TextEncoder().encode(textToSend)
const textToSend = 'Hello from TypeScript!';
const encodedTextToSend = new TextEncoder().encode(textToSend);

// send the message
serial.send(encodedTextToSend, encodedTextToSend.length);
Expand All @@ -113,13 +115,13 @@ void loop() {

`main.ts`
```typescript
import { Serial } from "./mod.ts";
import { Serial, baudrate } from "./mod.ts";

// create new instance of a serial object
const serial = new Serial();

// open the connection
serial.open();
serial.open('COM1', baudrate.B9600);

// create a new buffer to store incoming bytes,
// in this example we want to read a maximum of 100 bytes
Expand Down
Loading