@arendi/testing
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

BLT2450 WebSocket client API

This package contains JavaScript source files for communicating with the Arendi WebSocket server.

Prerequisite

WebSocket server

An instance of the WebSocket server must be running in order for the following sample code to run. To install the WebSocket server, download and execute the installer from https://www.arendi.ch/blt2450

Node

Node.js (at least v16) must be installed on the target machine: https://nodejs.org


Installation

Install using npm:

npm install @arendi/testing

Usage

DTM measurement

Get list of all BLT2450 tester and DUT

const {
  Api,
  WsInterface,
  TesterTxPower,
  DtmChannel,
  DtmPattern,
  DtmBytes,
  DtmPhy,
  Protocol,
  Baudrate,
  Handshake,
  Parity,
  Specification
} = require('@arendi/testing');

// Create WebSocket interface and API instance
const wsInterface = new WsInterface();
const api = new Api(wsInterface);

// Open WebSocket interface
await wsInterface.Open({ url: 'ws://localhost:5000/blt24/', protocols: undefined });

// Request tester list, print serial number(s) to console
await api.GetTesterList();
api.TesterList.list.forEach(tester => console.log(tester.serialNumber));

// Request DUT list, print identifier(s) to console
await api.GetDutList();
api.DutList.list.forEach(dut => console.log(dut.identifier));

Start DTM Tx test

// Get BLT2450 tester with a given serial number
// If successful, activate DTM Tx test
const tester = api.TesterList.Get('123456789ABC-09'); // enter valid serial number
if (tester) {
  await tester.SetDtmMode();
  await tester.DtmTxStart(
    DtmChannel.Ch19, // 2.44 GHz
    DtmBytes.B37, // 37 bytes
    DtmPattern.Prbs9, // PRBS9 pattern
    DtmPhy.Phy1Mbps, // 1 Mbps PHY
    30, // 30db attenuation -> -30 dBm output power
    0 // output power, don't change!
  );
}

Start DTM Rx test

// Get DUT with a given identifier (COM port)
// If successful, open COM port and activate DTM Rx test
const dut = api.DutList.Get('COM1'); // enter valid COM port
if (dut) {
  await dut.Connect(Protocol.TwoWire, Baudrate.B19200, Handshake.None, Parity.None, Specification.V5_0); // enter valid settings
  await dut.DtmRxStart(
    DtmChannel.Ch19, // 2.44 GHz
    DtmBytes.B37, // 37 bytes
    DtmPattern.Prbs9, // PRBS9 pattern
    DtmPhy.Phy1Mbps, // 1 Mpbs PHY
    0, // attenuation, don't change!
    1000 // 1s measurement interval
  );
}

// Read DTM measurements using async await
// This is useful for "synchronous" programming
const measurement = await dut.ReadDtmData();
console.log(
  `PER: ${measurement.per}% (received packets: ${measurement.count}, measurement interval: ${measurement.intervalMs}ms)`
);

// OR

// Read measurements using events
// This is useful for asynchronous programming
dut.OnDtmEvent(measurement => {
  console.log(
    `PER: ${measurement.per}% (received packets: ${measurement.count}, measurement interval: ${measurement.intervalMs}ms)`
  );
});

Cleanup

// Stop DTM mode
await tester.DtmStop();
await dut.DtmStop();

// Cleanup
tester.Dispose(); // cleanup, remove event handlers
await dut.Disconnect(); // release COM port
dut.Dispose(); // cleanup, remove event handlers

// Close WebSocket interface, release resources
await wsInterface.Close();
wsInterface.Dispose();

More examples

For more examples check out the files from the examples folder. To run an example, execute the following command from within your working directory:

node node_modules/@arendi/testing/examples/<insert_filename_here>

Package Sidebar

Install

npm i @arendi/testing

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

975 kB

Total Files

79

Last publish

Collaborators

  • arendi