Skip to content

Instantly share code, notes, and snippets.

View erossignon's full-sized avatar

Etienne erossignon

View GitHub Profile
import * as fs from 'fs';
import { OPCUAServer, nodesets, Variant, DataType, StatusCodes } from 'node-opcua';
(async () => {
const data = await fetch("https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/2f76ebcfa097cde42414bea08abf04423f30ea4e/PlasticsRubber/GeneralTypes/1.03/Opc.Ua.PlasticsRubber.GeneralTypes.NodeSet2.xml");
const filename = "./Opc.Ua.PlasticsRubber.GeneralTypes.NodeSet2.xml";
fs.writeFileSync(filename, await data.text());
@erossignon
erossignon / getEndpointBasic.js
Created October 13, 2020 09:21
simple script to get OPCUA server endpoint
const { OPCUAClient, SecurityPolicy, MessageSecurityMode } = require("node-opcua");
const endpointUri = process.argv[2] || "opc.tcp://opcuademo.sterfive.com:26543";
(async () => {
try {
console.log("connecting to ", endpointUri);
const client = OPCUAClient.create({ endpoint_must_exist: false });
client.on("backoff", () => {
$ ssh pi@raspberrypi
pi@raspberrypi's password:
Linux raspberrypi 5.4.51-v7l+ #1327 SMP Thu Jul 23 11:04:39 BST 2020 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
@erossignon
erossignon / get_endpoints.ts
Created May 27, 2020 18:32
Get OPCUA Server Endpoints
#!/usr/bin/env ts-node
// tslint:disable:no-console
import * as chalk from "chalk";
import * as fs from "fs";
import * as path from "path";
import * as yargs from "yargs";
import {
ApplicationType,
coerceMessageSecurityMode,
// mkdir myproj
// cd myproj
// npm init
// npm install node-opcua
// => copy this file
// node --inspect-brk test_server.js
const path = require("path");
const fs = require("fs");
@erossignon
erossignon / test_server.ts
Last active November 12, 2019 14:59
server with hardcoded ip address in certifcate
// node --inspect-brk -r ts-node/register -r source-map-support test_server.ts
import * as path from "path";
import * as fs from "fs";
import { promisify } from "util";
import * as child_process from "child_process";
import {
makeApplicationUrn,
OPCUAServer,
OPCUAClient,
const chalk = require("chalk");
const {
OPCUAServer ,
OPCUACertificateManager
} = require("node-opcua");
const certificateManager = new OPCUACertificateManager({
@erossignon
erossignon / demo655.js
Last active August 10, 2019 09:59
crawl large number of node in node-opcua
const { OPCUAClient , NodeCrawler} = require("node-opcua");
const async = require("async");
const util = require("util");
const client = OPCUAClient.create({
endpoint_must_exist: false
});
// UA Automation Ansi Demo Server
const endpointUrl = "opc.tcp://localhost:48020";
@erossignon
erossignon / Dockerfile
Created February 26, 2019 20:10
Docker file to run node-red-contrib-iiot-opcua tests in a container
# docker build . -t node-red-contrib-iiot-opcua
# docker run node-red-contrib-iiot-opcua
FROM mhart/alpine-node
RUN apk add git make python g++ openssl
RUN cd /home && git clone https://github.com/biancode/node-red-contrib-iiot-opcua.git
RUN cd /home/node-red-contrib-iiot-opcua && \
git reset HEAD --hard && \
git fetch && \
git checkout develop && \
@erossignon
erossignon / server_with_20000_variables.js
Created December 16, 2018 15:29
server with 20k variables
/* global console, require */
const opcua = require("node-opcua");
const server = new opcua.OPCUAServer({
port: 26543 // the port of the listening socket of the server
});
function post_initialize() {
const addressSpace = server.engine.addressSpace;