-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SBG-ECOM-NODERED: v0.0.1 with the minimum to be publish
- Loading branch information
Showing
23 changed files
with
2,405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: sbg-ecom-nodered | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- packages/sbg-ecom-nodered/** | ||
|
||
jobs: | ||
# test: | ||
# name: 🧪 Test | ||
# runs-on: ubuntu-latest | ||
|
||
# strategy: | ||
# matrix: | ||
# node-version: [18.x, 20.x] | ||
|
||
# steps: | ||
# - name: 👍 Checkout | ||
# uses: actions/checkout@v3 | ||
|
||
# - name: ❇️ Setup node.js | ||
# uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: ${{ matrix.node-version }} | ||
# cache: 'npm' | ||
|
||
# - name: 📥 Install Dependencies | ||
# run: npm install | ||
|
||
# - name: 🧑🔬 Tests | ||
# run: "npm run norsub-emru-nodered:test" | ||
|
||
publish: | ||
name: 🚀 Publish | ||
runs-on: ubuntu-latest | ||
# needs: test | ||
if: github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: 👍 Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: ❇️ Setup node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: 📥 Install Dependencies | ||
run: npm install | ||
|
||
# - name: 🛠️ Build | ||
# run: "npm run norsub-emru-nodered:build" | ||
|
||
- name: 🚀 Publish to npm | ||
run: "npm publish --access public --workspace=@coremarine/sbg-ecom-nodered" | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# IDEs | ||
.vscode | ||
.idea | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Node-Red | ||
.config.*.json | ||
.config.*.json.backup | ||
.flows* | ||
flows_cred.json | ||
tests/nodered/data/package.json | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM nodered/node-red:latest-18 | ||
|
||
USER root | ||
RUN mkdir -m 777 /components && chown node-red:node-red /components\ | ||
&& mkdir -m 777 /config && chown node-red:node-red /config \ | ||
&& mkdir -m 777 /db && chown node-red:node-red /db \ | ||
&& mkdir -m 777 /static && chown node-red:node-red /static \ | ||
&& mkdir -m 777 /tests && chown node-red:node-red /tests | ||
COPY --chown=node-red:node-red --chmod=777 tests/nodered/components/ /components/ | ||
|
||
USER node-red | ||
|
||
RUN npm i --production @coremarine/sbg-ecom /components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 CoreMarine | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# NMEA-Parser-NodeRED | ||
|
||
![npm (scoped)](https://img.shields.io/npm/v/%40coremarine/sbg-ecom-nodered) | ||
[![publish](https://github.com/core-marine-dev/devices/actions/workflows/sbg-ecom-nodered.yml/badge.svg)](https://github.com/core-marine-dev/devices/actions/workflows/sbg-ecom-nodered.yml) | ||
![npm](https://img.shields.io/npm/dy/%40coremarine/sbg-ecom-nodered) | ||
|
||
sbg-ecom | ||
|
||
Node-Red component to read NMEA 0183 sentences. It is a wrapper of [@coremarine/nmea-parser](https://www.npmjs.com/package/@coremarine/nmea-parser) (check it docs). | ||
|
||
## Input | ||
|
||
NMEA component uses 5 properties to work: | ||
|
||
- `payload` is the main property with NMEA content. | ||
- `protocols`, `sentence`, `memory` and `fake` are optionals. | ||
|
||
| Input property | Description | | ||
| :--------------------- | :------------------------------------------------------------------------------------- | | ||
| `payload` (string) | NMEA ASCII content (important, it is an *ASCII* string, not other encoding). | | ||
| *`memory`* (object) | Object to check or enabled / disabled parser memory state (look details below). | | ||
| *`protocols`* (object) | Object to get or set the protocols supported and their sentences (look details below). | | ||
| *`sentence`* (string) | Sentence ID to get if it is supported and its info (look details below). | | ||
| *`fake`* (string) | Sentence ID to get a full fake NMEA-like sentence if it is supported. | | ||
|
||
## Output | ||
|
||
Each input proerty would be responded in the same output property | ||
|
||
| Output property | Description | | ||
| :--------------------- | :----------------------------------------------------------------------------------------------------------------------------- | | ||
| payload (array) | It gives you the same parsing output that the CoreMarine NMEA Parser (an array of object with the info of each NMEA sentence). | | ||
| *`memory`* (object) | Response to the *memory* input (look details below). | | ||
| *`protocols`* (object) | Response to the *protocols* input (look details below). | | ||
| *`sentence`* (string) | Response to the *sentence* input (look details below). | | ||
| *`fake`* (string) | Response to the *fake* input (look details below). | | ||
|
||
## Details | ||
|
||
NMEA parser translate NMEA ASCII string data into a JavaScript objects (one for each | ||
NMEA 0183 sentence). Each time it receives data from payload input, it gives the parsed sentences to payload output. | ||
|
||
It just a wrapper of the npm library [@coremarine/nmea-parser](https://www.npmjs.com/package/@coremarine/nmea-parser) (take a look on it). | ||
|
||
To interact with the *memory* | *protocols* | *sentence* API is through the `memory` | `protocols` | `sentence` property: | ||
|
||
- If you request something in `msg.memory` | `msg.protocols` | `msg.sentence` input | ||
- The response will be in `msg.memory` | `msg.protocols` | `msg.sentence` output | ||
|
||
### Memory | ||
|
||
It is enabled by default: | ||
|
||
- memory enabled: Every time you inject data, it's attached to the internal data. | ||
- memory disabled: Every time you inject data, it clears internal data and add new one. | ||
|
||
Internally it has a buffer with a max number of characters | ||
|
||
| Input | Output | | ||
| :------------------------------------------------------: | :-----------------------------------------------------------: | | ||
| `memory`: { `command`: `"set"`, `payload`: **boolean** } | `memory`: { `memory`: **boolean**, `characters`: **number** } | | ||
| `memory`: { `command`: `"get"` } | `memory`: { `memory`: **boolean**, `characters`: **number** } | | ||
|
||
### Protocols | ||
|
||
The parser can be feeded or expanded to understand more nmea sentences, standard or propietary. | ||
To do that it should be passed an object with the property `command` equal to `"set"` and one this three properties: | ||
|
||
1. `file`: It's the string file path to the protocols YAML file. | ||
2. `content`: It's the string content of the protocols YAML file. | ||
3. `protocols`: It's the JS object after parsing the protocols YAML file. | ||
|
||
If you send more of them, parser only will read one (`file` upper other, `content` upper `protocols`) | ||
|
||
If you just want to know what are the known or supported sentences, you just need the command `get`. | ||
|
||
| Input | Output | | ||
| :----------------------------------------------------------: | :--------------------: | | ||
| `protocols`: { `command`: `"set"`, `file`: **string** } | `protocols`: **array** | | ||
| `protocols`: { `command`: `"set"`, `content`: **string** } | `protocols`: **array** | | ||
| `protocols`: { `command`: `"set"`, `protocols`: **object** } | `protocols`: **array** | | ||
| `protocols`: { `command`: `"get"` } | `protocols`: **array** | | ||
|
||
### Sentence | ||
|
||
If you want to know if a sentence is known / supported, you need to send the sentence id. | ||
Response will be an `object` with the whole info or `null` if it's unknown / not supported yet. | ||
|
||
| Input | Output | | ||
| :--------------------: | :------------------------------: | | ||
| `sentence`: **string** | `sentence`: **object** \| `null` | | ||
|
||
### Fake | ||
|
||
If you want to get a NMEA-like sentence, maybe just to do some tests, you need to send the sentence id. | ||
Response will be a `string` with the whole ASCII sentence or `null` if it's unknown / not supported yet. | ||
This fake sentence is correct in terms of NMEA requirements but each field has garbage. | ||
|
||
| Input | Output | | ||
| :----------------: | :--------------------------: | | ||
| `fake`: **string** | `fake`: **string** \| `null` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# version: '3' | ||
name: sbg-ecom | ||
|
||
services: | ||
nodered: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- 1880:1880 | ||
volumes: | ||
# Node-Red working files | ||
- ./tests/nodered/data:/data | ||
- ./tests/nodered/tests:/tests |
Oops, something went wrong.