Skip to content

Commit 278a9d3

Browse files
committedFeb 15, 2022
Initial work derived from marty2js and Marty app
0 parents  commit 278a9d3

38 files changed

+15508
-0
lines changed
 

‎.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = 0
14+
trim_trailing_whitespace = true

‎.eslintrc.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint',
6+
],
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
],
11+
};

‎.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Auto detect text files and perform LF normalization
2+
* text eol=lf
3+

‎.github/ISSUE_TEMPLATE.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Expected Behavior
2+
3+
4+
## Actual Behavior
5+
6+
7+
## Steps to Reproduce the Problem
8+
9+
1.
10+
1.
11+
1.
12+
13+
## Specifications
14+
15+
- Version:
16+
- Platform:

‎.github/PULL_REQUEST_TEMPLATE.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Fixes #<issue_number_goes_here>
2+
3+
> It's a good idea to open an issue first for discussion.
4+
5+
- [ ] Tests pass
6+
- [ ] Appropriate changes to README are included in PR

‎.github/workflows/deploy-gh-pages.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Builds the docs and deploys to GitHub pages
3+
#
4+
# https://github.com/actions/setup-node
5+
# Using https://github.com/marketplace/actions/deploy-to-github-pages
6+
name: Deploy to Github pages
7+
8+
on:
9+
push:
10+
#tags:
11+
# - v*
12+
branches:
13+
- master
14+
15+
jobs:
16+
deploy_pages:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions/setup-node@v2
22+
with:
23+
node-version: '12'
24+
cache: 'yarn'
25+
- run: yarn install
26+
- run: yarn docs
27+
28+
- run: touch docs/.nojekyll
29+
- name: Deploy docs 🚀
30+
uses: JamesIves/github-pages-deploy-action@releases/v3
31+
with:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
BRANCH: gh-pages # The branch the action should deploy to.
34+
FOLDER: docs # The folder the action should deploy.

‎.github/workflows/lint-and-test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint and test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_and_test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
nodejs: [10, 12, 14]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
# https://github.com/actions/setup-node
17+
- uses: actions/setup-node@v2-beta
18+
with:
19+
node-version: ${{ matrix.nodejs }}
20+
21+
- run: yarn install
22+
- run: yarn add -D esbuild
23+
- run: yarn test
24+
- run: yarn lint
25+
- run: yarn build-all

‎.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/node_modules/
2+
/build/
3+
/lib/
4+
/dist/
5+
/docs/
6+
.idea/*
7+
8+
.DS_Store
9+
coverage
10+
*.log

‎.gitlab-ci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
image: node:12
2+
3+
cache:
4+
paths:
5+
- node_modules/
6+
7+
stages:
8+
- test
9+
- deploy
10+
11+
lint-and-test:
12+
stage: test
13+
script:
14+
- yarn install
15+
- yarn add -D esbuild
16+
- yarn test
17+
- yarn lint
18+
- yarn build-all
19+
20+
# Deploy docs to Gitlab pages
21+
pages:
22+
stage: deploy
23+
only:
24+
- master
25+
script:
26+
- yarn install
27+
- yarn docs
28+
- mv docs public
29+
artifacts:
30+
paths:
31+
- public

‎.npmignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/.github/
2+
/.vscode/
3+
/node_modules/
4+
/build/
5+
/tmp/
6+
.idea/*
7+
/docs/
8+
9+
coverage
10+
*.log
11+
.gitlab-ci.yml
12+
13+
package-lock.json
14+
/*.tgz
15+
/tmp*
16+
/mnt/
17+
/package/

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Robotical
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

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @robotical/ricjs
2+
Javascript/TS library for Robotical RIC
3+
4+
## Install
5+
6+
```bash
7+
$ npm install @robotical/ricjs
8+
```
9+
10+
## Usage
11+
12+
```js
13+
```

‎__tests__/RICMiniHCLC.test.ts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import RICMiniHDLC from '../src/RICMiniHDLC';
2+
// import RICUtils from '../src/RICUtils';
3+
4+
test('HDLC simple encode', () => {
5+
const hdlc = new RICMiniHDLC();
6+
const encodedBuf = hdlc.encode(new Uint8Array([72, 101, 108, 108, 111]));
7+
// console.log(RICUtils.bufferToHex(encodedBuf));
8+
expect(encodedBuf).toEqual(new Uint8Array([
9+
hdlc.FRAME_BOUNDARY_OCTET,
10+
72,
11+
101,
12+
108,
13+
108,
14+
111,
15+
0xda,
16+
0xda,
17+
hdlc.FRAME_BOUNDARY_OCTET,
18+
]));
19+
});
20+
21+
test('HDLC simple decode', () => {
22+
const hdlc = new RICMiniHDLC();
23+
24+
const testMsg = new Uint8Array(
25+
[
26+
hdlc.FRAME_BOUNDARY_OCTET,
27+
'H'.charCodeAt(0),
28+
'e'.charCodeAt(0),
29+
'l'.charCodeAt(0),
30+
'l'.charCodeAt(0),
31+
'o'.charCodeAt(0),
32+
0xda,
33+
0xda,
34+
hdlc.FRAME_BOUNDARY_OCTET,
35+
]);
36+
37+
let frameReceived: Uint8Array = new Uint8Array(0);
38+
39+
function onHDLCFrame(rxFrame: Uint8Array) {
40+
frameReceived = rxFrame;
41+
}
42+
43+
hdlc.onRxFrame = onHDLCFrame.bind(this);
44+
45+
hdlc.addRxBytes(testMsg);
46+
47+
expect(frameReceived).toEqual(new Uint8Array([72, 101, 108, 108, 111]));
48+
});
49+
50+

‎jest.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
roots: ['<rootDir>'],
3+
testMatch: [
4+
"**/__tests__/**/*.+(ts|tsx|js)",
5+
"**/?(*.)+(spec|test).+(ts|tsx|js)"
6+
],
7+
transform: {
8+
"^.+\\.(ts|tsx)$": "ts-jest"
9+
},
10+
}

0 commit comments

Comments
 (0)
Please sign in to comment.