Dave Conway-Jones 2e52257afa
Tidy up PR, add status to control nodes
tweak help, readme, and feed stopped status to other nodes.
2023-11-23 12:11:59 +00:00

143 lines
7.4 KiB
HTML

<script type="text/html" data-help-name="serial in">
<p>Reads data from a local serial port.</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string | buffer</span></dt>
<dd>received data via the serial port</dd>
<dt>port <span class="property-type">string</span></dt>
<dd>name of the serial port</dd>
</dl>
<p>The node can either
<ul>
<li>wait for a "split" character (default \n).
Also accepts escaped shortcut (e.g. \n) or hex notation (0x0d).</li>
<li>wait for a timeout in milliseconds from the first character received.</li>
<li>wait for a silence time in milliseconds after the last character received.</li>
<li>wait to fill a fixed sized buffer.</li>
</ul>
</p>
<p>It then outputs <code>msg.payload</code> as either a UTF-8 ASCII string or a binary buffer object.</p>
<p><code>msg.port</code> is set to the name of the port selected.</p>
<p>If no split character is specified, or a timeout or buffer size of 0,
then a stream of single characters is sent -
again either as ASCII chars or size 1 binary buffers.</p>
</script>
<script type="text/html" data-help-name="serial out">
<p>Send data via a local serial port.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string | buffer</span></dt>
<dd>data to be sent via the serial port</dd>
<dt class="optional">baudrate <span class="property-type">string</span></dt>
<dd>baudrate of the serial port (optional)</dd>
</dl>
<p>Only the <code>msg.payload</code> is sent.</p>
<p>Optionally the baudrate can be changed using <code>msg.baudrate</code>.</p>
<p>Optionally the new line character used to split the input
can be appended to every message sent out to the serial port.</p>
<p>Binary payloads can be sent by using a buffer object.</p>
</script>
<script type="text/html" data-help-name="serial request">
<p>Provides a connection to a request/response serial port.</p>
<p>This node behaves as a tightly coupled combination of <code>serial in</code> and <code>serial out</code> nodes,
with which it shares the configuration.</p>
<p>Send the request message in <code>msg.payload</code> as you would do with a <code>serial out</code> node.
The message will be forwarded to the serial port following a strict FIFO (First In, First Out) queue,
waiting for a single response before transmitting the next request.
Once a response is received (with the same logic of a <code>serial in</code> node), or after a timeout occurs,
a message is sent to the output (see Outputs below),
with <code>msg.payload</code> containing the received response (or missing in case if timeout) and
all other properties are preserved.</p>
<p>For consistency with the <code>serial in</code> node, <code>msg.port</code> is set to the name of the port selected.</p>
<h3>Inputs</h3>
<ul>
<li><code>msg.timeout</code> is the timeout (in ms) after which the incoming message is propagated
to the output with <code>msg.status</code> set to <code>"ERR_TIMEOUT"</code> and missing payload.
If not present, the default value is 10000 (10s).</li>
<li><code>msg.count</code> if set this will override the configured number of characters
as long as it is less than the number configured.</li>
<li><code>msg.waitfor</code> must be a single character, escape code, or hex code.
If set, the node will wait until it matches that character in the stream and then start the output.</li>
<li>Optionally the baudrate can be changed using <code>msg.baudrate</code></li>
</ul>
<h3>Outputs</h3>
<ul>
<li><code>msg.payload</code> is the response. If no response occured, this property is removed.</li>
<li><code>msg.status</code> is <code>"OK"</code> in case a response is received,
or <code>"ERR_TIMEOUT"</code> if a timeout occurs.</li>
<li>Any other property coming from the input will be preserved.</li>
</ul>
</script>
<script type="text/html" data-help-name="serial-port">
<p>Configuration options for a local serial port.</p>
<p>The search button should return a list of available serial ports to choose from,
or you can type in the location if known.</p>
<p>The DTR, RTS, CTS and DSR switches can be used to permanently pull the corresponding flow control pin high or low,
e.g. in order to power devices via those pins.</p>
<p>The node can optionally wait until it matches a pre-defined character.</p>
<p>The serial data reception can either
<ul>
<li>wait for a "split" character (default \n). Also accepts escaped shortcut (e.g. \n) or hex notation (0x0d).</li>
<li>wait for a timeout in milliseconds from the first character received.</li>
<li>wait for a silence time in milliseconds after the last character received.</li>
<li>wait to fill a fixed sized buffer.</li>
</ul>
</p>
<p>It then outputs the received data as either a UTF-8 ASCII string or a binary buffer object.</p>
<p>If no split character is specified, or a timeout or buffer size of 0, then a stream of single characters is sent -
again either as ASCII chars or size 1 binary buffers.</p>
<p>Optionally the new line character used to split the input
can be appended to every message sent out to the serial port.</p>
</script>
<script type="text/html" data-help-name="serial control">
<p>Stops, starts the serial communication and changes the serial port configuration.</p>
<p>This node provides the ability to:</p>
<ul>
<li>stop the communication and release the serial port.</li>
<li>reopen the port and restart the communications.</li>
<li>change the serial port and the configuration dynamically.</li>
<li>query the serial port configuration.</li>
</ul>
<h3>Inputs</h3>
<p>In order to control the communication, just send <b>msg.payload</b> containing.</p>
<pre>
{
"serialport": "/dev/ttyUSB0",
"serialbaud": 115200,
"databits": 8,
"parity": "none",
"stopbits": 1,
"enabled": true
}
</pre>
<p>The following optional parameters will change the configuration only if they are present.</p>
<p>Any combination of them can be passed to change/control the serial communication</p>
<ul>
<li> serialport </li>
<li> serialbaud </li>
<li> databits </li>
<li> parity </li>
<li> stopbits </li>
<li> dtr </li>
<li> rts </li>
<li> cts </li>
<li> dsr </li>
<li> enabled </li>
</ul>
<p>If the <code>enabled</code> property is not present, it will default to <code>true</code>.</p>
<p>
<code>{"enabled":true}</code> or <code>{"enabled":false}</code> will start or stop the communication.</p>
<p>If <code>enabled</code> is passed along with other parameters, the configuration will be changed and the
port will be either started or remain stopped, ready to be started later depending on its value.</p>
<h3>Outputs</h3>
<p><code>msg.payload</code> containing the serial port configuration.</p>
</script>