How to use the node-opcua-debug.hexDump function in node-opcua-debug

To help you get started, we’ve selected a few node-opcua-debug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / client / client_secure_channel_layer.ts View on Github external
if (chunk) {

            /**
             * notify the observer that a message chunk is about to be sent to the server
             * @event send_chunk
             * @param message_chunk {Object}  the message chunk
             */
            this.emit("send_chunk", chunk);

            /* istanbul ignore next */
            if (doDebug && checkChunks) {
                verify_message_chunk(chunk);
                debugLog(chalk.yellow("CLIENT SEND chunk "));
                debugLog(chalk.yellow(messageHeaderToString(chunk)));
                debugLog(chalk.red(hexDump(chunk)));
            }
            assert(this._transport);
            this._transport.write(chunk);
            requestData.chunk_count += 1;

        } else {
            // last chunk ....

            /* istanbul ignore next */
            if (doDebug && checkChunks) {
                debugLog(chalk.yellow("CLIENT SEND done."));
            }
            if (requestData) {
                if (doPerfMonitoring) {
                    requestData._tick1 = get_clock_tick();
                }
github node-opcua / node-opcua / packages / node-opcua-factory / source / factories_baseobject.ts View on Github external
function _arrayEllipsis(value: any[] | null) {

    if (!value) {
        return "null []";
    } else {
        if (value.length === 0) {
            return "[ /* empty*/ ]";
        }
        assert(_.isArray(value));
        const v = [];
        const m = Math.min(_nbElements, value.length);
        for (let i = 0; i < m; i++) {
            let element = value[i];
            if (element instanceof Buffer) {
                element = hexDump(element, 32, 16);
            }
            v.push(!utils.isNullOrUndefined(element) ? element.toString() : null);
        }
        return "[ " + v.join(",") + (value.length > 10 ? " ... " : "") + "] (l=" + value.length + ")";
    }
}
github node-opcua / node-opcua / packages / node-opcua-secure-channel / src / client / client_secure_channel_layer.js View on Github external
ClientSecureChannelLayer.prototype._on_receive_message_chunk = function (message_chunk) {

    const self = this;

    /* istanbul ignore next */
    if (doDebug) {
        const _stream = new BinaryStream(message_chunk);
        const messageHeader = readMessageHeader(_stream);
        debugLog("CLIENT RECEIVED " + (JSON.stringify(messageHeader) + "").yellow);
        debugLog("\n" + hexDump(message_chunk).blue);
        debugLog(messageHeaderToString(message_chunk));
    }
    self.messageBuilder.feed(message_chunk);
};
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / client / client_secure_channel_layer.ts View on Github external
private _on_receive_message_chunk(messageChunk: Buffer) {

        /* istanbul ignore next */
        if (doDebug1) {
            const _stream = new BinaryStream(messageChunk);
            const messageHeader = readMessageHeader(_stream);
            debugLog("CLIENT RECEIVED " + chalk.yellow(JSON.stringify(messageHeader) + ""));
            debugLog("\n" + hexDump(messageChunk));
            debugLog(messageHeaderToString(messageChunk));
        }
        this.messageBuilder.feed(messageChunk);
    }
github node-opcua / node-opcua / packages / node-opcua-secure-channel / test_helpers / mock / mock_transport.ts View on Github external
replies.push(reply);
                } else {
                    replies = reply;
                }
                assert(replies.length >= 1, " expecting at least one reply " + JSON.stringify(reply));
                replies.forEach((reply1: any) => {
                    debugLog("\nFAKE SERVER SEND");
                    debugLog(chalk.red(hexDump(reply1)));
                    this._mockTransport.server.write(reply1);
                });

            } else {
                const msg = " MockServerTransport has no more packets to send to client to" +
                  " emulate server responses.... ";
                console.log(chalk.red.bold(msg));
                console.log(chalk.blue.bold(hexDump(data)));

                display_trace_from_this_projet_only();
                analyseExtensionObject(data, 0, 0, {});

                this.emit("done");
            }
        });
    }
github node-opcua / node-opcua / packages / node-opcua-packet-analyzer / source / packet_analyzer / packet_analyzer.ts View on Github external
export function analyze_object_binary_encoding(obj: BaseUAObject) {

    assert(obj);

    const size = obj.binaryStoreSize();
    console.log("-------------------------------------------------");
    console.log(" size = ", size);
    const stream = new BinaryStream(size);
    obj.encode(stream);

    stream.rewind();
    console.log("-------------------------------------------------");
    if (stream.buffer.length < 256) {
        console.log(hexDump(stream.buffer));
        console.log("-------------------------------------------------");
    }

    const reloadedObject = new (obj.constructor as any)();
    analyzePacket(stream.buffer, reloadedObject, 0);

}
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_builder.ts View on Github external
this.messageChunks.forEach((messageChunk) => {
                console.log(" ---------------- chunk i=", i++);
                console.log(hexDump(messageChunk));
            });
            return false;
github node-opcua / node-opcua / packages / node-opcua-factory / src / factories_baseobject.js View on Github external
function _dump_simple_value(self, field, data, value, fieldType) {

        let str = "";
        if (value instanceof Buffer) {

            const _hexDump = hexDump(value);
            data.lines.push(fieldName_f + " " + fieldType_f);
            data.lines.push("BUFFER{" + _hexDump + "}");

        } else {


            if (field.isArray) {

                str = fieldName_f + " " + fieldType_f + ": " + _array_ellypsis(value,field);

            } else {
                if (fieldType === "IntegerId" || fieldType === "UInt32") {

                    value = "" + value + "               0x" + value.toString(16);

                } else if (fieldType === "DateTime" || fieldType === "UtcTime") {
github node-opcua / node-opcua / packages / node-opcua-factory / source / factories_baseobject.ts View on Github external
function _dump_simple_value(self: BaseUAObject, field: StructuredTypeField, data: any, value: any, fieldType: string) {

        let str = "";
        if (value instanceof Buffer) {
            const _hexDump = hexDump(value);
            data.lines.push(fieldNameF + " " + fieldTypeF);
            data.lines.push("BUFFER{" + _hexDump + "}");

        } else {

            if (field.isArray) {
                str = fieldNameF + " " + fieldTypeF + ": " + _arrayEllipsis(value);
            } else {
                if (fieldType === "IntegerId" || fieldType === "UInt32") {
                    value = "" + value + "               " + ((value !== undefined ) ? "0x"+value.toString(16) : "undefined");
                } else if (fieldType === "DateTime" || fieldType === "UtcTime") {
                    value = (value && value.toISOString) ? value.toISOString() : value;
                } else if (typeof value === "object" && value !== null && value !== undefined) {
                    value = value.toString.apply(value, args);
                }
                str = fieldNameF + " " + fieldTypeF + ": "
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_header_to_string.ts View on Github external
assert(stream.length === 8);

    const channelId = stream.readUInt32();
    securityHeader.decode(stream);
    sequenceHeader.decode(stream);

    const slice = messageChunk.slice(0, stream.length);

    return messageHeader.msgType + " " +
        messageHeader.isFinal +
        " length   = " + messageHeader.length +
        " channel  = " + channelId +
        " seqNum   = " + sequenceHeader.sequenceNumber +
        " req ID   = " + sequenceHeader.requestId +
        " security   = " + securityHeader.toString() +
        "\n\n" + hexDump(slice);
}