node-red-contrib-canal
Version:
CANAL (CAN abstraction error) interface node for node-red
199 lines (188 loc) • 7.12 kB
HTML
<!--
///////////////////////////////////////////////////////////////////////////
// canal.html
//
// CANAL interface
//
// This file is part of the VSCP (https://www.vscp.org)
//
// The MIT License (MIT)
//
// Copyright © 2020 Ake Hedman, Grodans Paradis AB
// <info@grodansparadis.com>
//
// 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.
//
-->
<script type="text/html" data-template-name="canal">
<div class="form-row">
<label for="node-input-driver"><i class="icon-tag"></i> Driver</label>
<input type="text" id="node-input-driver" placeholder="CANAL Driver">
</div>
<div class="form-row">
<label style="margin-left: 100px; width: 70%">
<input
type="checkbox"
id="node-input-bvscp"
placeholder=""
style="width: 20px; margin: -4px 0 0 0;"
/>
Use VSCP translation
</label>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="canal">
<p>A node that send and receive CAN messages (and VSCP events) to/from a CANAL driver. A CAN message
is the least common denominator when it comes to network transport for VSCP and
this node can therefore be used to send/receive level I VSCP events.
</p>
<p>
CANAL stands for CAN Abstraction Layer. VSCP stands for Very Simple Control Protocol.
</p>
<p>
Select Use VSCP translation to make it possible to send VSCP events
directly. This also automatically translate CAN messages to
events on the output.
</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dd> the payload is the message (or VSCP event) to send to the configured CANAL driver.
It can either be a JSON object or a string.
</dd>
<dt class="optional">payload <span class="property-type">object</span></dt>
<dd> The CAN message is defined as a JSON object with the following payload format
<pre>
{
"ext":false,
"rtr":false,
"canid":123,
"dlc":5,
"data":[1,2,3,4,5]}
}
</pre>
<ul>
<li> <b>ext</b> - Marks the message as an extended id message.</li>
<li> <b>rtr</b> - The message is a remote transmission request. No data should be specified in this case (set to null).</li>
<li> <b>canid</b> - The canid for the CAN message. Must be less then 0x7ff for a standard CAN message.</li>
<li> <b>dlc</b> - Number of data bytes, 0-8. </li>
<li> <b>data</b> - An array, comma separated list or buffer with data bytes. Set to null if no data.</li>
</ul>
</dd>
<dt class="optional">payload <span class="property-type">string</span></dt>
<dd> The CAN message is defined as a string with the following payload format
<pre>
<canid>#{R|data}
</pre>
<ul>
<li> <b>canid</b> - Less than 0x7ff and with less than three digits for a standard id. Always defined in hex format.</li>
<li> <b>data</b> - The data part for the can frame. Always in hex format.</li>
<li> <b>R</b> - Specifies a remote transmission request frame.</li>
</ul>
<p>
<b>Examples</b>
<pre>
123#DEADBEEF - standard frame
5AA# - Standard frame no data
1F334455#1122334455667788 - extended frame
123#R - for remote transmission request.
</pre>
</p>
</dd>
<dd>
If <b>'Use VSCP translation'</b> is selected then it is possible to directly send VSCP
events. VSCP events have the following format
</dd>
<dd>
<pre>
{ "vscpHead":0,
"vscpObId":0,
"vscpClass":10,
"vscpType":6,
"vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
"vscpTimeStamp":1234567,
"vscpDateTime":"2018-03-03T12:01:40Z",
"vscpData":[1,2,3,4],
}
</pre>
</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>the output is in the form of a
JSON object with the following content.
</dd>
<pre>
{
"ext":false,
"rtr":false,
"canid":123,
"dlc":5,
"data":[1,2,3,4,5]}
}
</pre>
<ul>
<li> <b>ext</b> - Marks the message as an extended id message.</li>
<li> <b>rtr</b> - The message is a remote transmission request. No data should be specified in this case (set to null).</li>
<li> <b>canid</b> - The canid for the CAN message. Must be less then 0x7ff for a standard CAN message.</li>
<li> <b>dlc</b> - Number of data bytes, 0-8. </li>
<li> <b>data</b> - An array, comma separated list or buffer with data bytes. Set to null if no data.</li>
</ul>
</dd>
<dd>
If <b>'Use VSCP translation'</b> is selected then output CAN messages will automatically be translated to VSCP
events. VSCP events have the following format
</dd>
<dd>
<pre>
{ "vscpHead":0,
"vscpObId":0,
"vscpClass":10,
"vscpType":6,
"vscpGuid":"ff:ee:dd:cc:bb:aa:99:88:77:66:55:44:33:22:11:00",
"vscpTimeStamp":1234567,
"vscpDateTime":"2018-03-03T12:01:40Z",
"vscpData":[1,2,3,4],
}
</pre>
</dd>
</ol>
</script>
<script type="text/javascript">
RED.nodes.registerType('canal',{
category: 'vscp',
color: '#ffe033',
defaults: {
name: {value:""},
driver: {value:"", type:"canaldrv-config", required:true},
bvscp: {value: 0}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-chain",
label: function() {
return this.name||"CANAL";
}
});
</script>