Skip to content

Instantly share code, notes, and snippets.

View erossignon's full-sized avatar

Etienne erossignon

View GitHub Profile
const chalk = require("chalk");
const {
OPCUAServer ,
OPCUACertificateManager
} = require("node-opcua");
const certificateManager = new OPCUACertificateManager({
@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,
// 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 / 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,
$ 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 / 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", () => {
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());