node-red-contrib-socketcan
Version:
node-red nodes for socketcan
134 lines (119 loc) • 5.01 kB
HTML
<!--
///////////////////////////////////////////////////////////////////////////
// send.html
//
// socketcan output node.
//
// This file is part of the VSCP (https://www.vscp.org)
//
// The MIT License (MIT)
//
// Copyright © 2020-2024 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/x-red" data-template-name="socketcan-in">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-config"><i class="fa fa-tasks"></i>Interface</label>
<input type="text" id="node-input-config" placeholder="vcan0">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="socketcan-in">
<p><b>socketcan-in</b> node is provided for sending CAN frames. You can send standard or extended id frames , FD frames are supported.
Set up the interface to some real CAN hardware or use a virtual interface.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dd> the payload is the message to send to the configured CAN bus interface.
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>
{
"canfd":false,
"ext":false,
"rtr":false,
"canid":123,
"dlc":5,
"data":[1,2,3,4,5]
}
</pre>
<ul>
<li> <b>canfd</b> - Define if the frame must be send as CANFD frame (if supported).</li>
<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.
123## - FD frame no data
123##AA - FD frame standard
</pre>
</p>
</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
This node has no outputs.
</ol>
</script>
<script type="text/javascript">
RED.nodes.registerType('socketcan-in',{
category: 'network',
color: '#bbff33',
defaults: {
name: {value:"socketcan-in"},
config: {type:"socketcan-config",required:true},
},
inputs:1,
outputs:0,
icon: "bridge.png",
label: function() {
return this.name || "socketcan-in";
},
labelStyle: function() {
return this.channel ? "node_label_italic" : "";
}
});
</script>