Skip to content

Commit 8aeff94

Browse files
committed
Debug node console output formats binary data as Hex
1 parent 1a469b6 commit 8aeff94

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nodered.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Timer from "timer";
2222
import deepEqual from "deepEqual";
2323
import structuredClone from "structuredClone";
2424
import Base64 from "base64";
25+
import Hex from "hex";
2526
import Modules from "modules";
2627
import fetch from "fetch";
2728
import {Headers, URLSearchParams} from "fetch";
@@ -343,13 +344,16 @@ class DebugNode extends Node {
343344
this.#statusVal = config.statusVal;
344345
}
345346
onMessage(msg) {
346-
const value = this.#getter(msg) ?? msg; //@@ temporary workaround for nodered2mcu bug ("complete msg object" returns undefined)
347+
let value = this.#getter(msg);
347348

348-
if (this.#console)
349+
if (this.#console) {
350+
if (value instanceof Uint8Array)
351+
value = Hex.toString(value);
349352
trace(("object" === typeof value) ? JSON.stringify(value) : value, "\n");
353+
}
350354

351355
if (this.#sidebar) {
352-
let value = this.#property ? {[this.#property]: value} : msg;
356+
value = this.#property ? {[this.#property]: value} : msg;
353357
value = {
354358
...value,
355359
source: {

0 commit comments

Comments
 (0)