rakusan2 / FRC-NT-Client

WPI NetworkTables Client for Node
https://www.npmjs.com/package/wpilib-nt-client
MIT License
21 stars 5 forks source link
frc javascript networktables

WPILIB Network Tables Client

This client uses version 3.0 of the Network Tables Protocol. With a failover to 2.0

Installation

npm install wpilib-nt-client

Usage

// Decleration
const ntClient = require('wpilib-nt-client');

const client = new ntClient.Client()

// Connects the client to the server on team 3571's roborio
client.start((isConnected, err) => {
    // Displays the error and the state of connection
    console.log({ isConnected, err });
}, 'roborio-3571.local');

// Adds a listener to the client
client.addListener((key, val, type, id) => {
    console.log({ key, val, type, id });
})

Constructor

Properties

Types

In 2.0

RPC Entry Definition

Remote Procedure Call

RPC:{
    // The name of the Call
    name,
    // The parameters of the call
    par:{
        // The Id of the type of the parameter
        typeId,
        // The name of the Type of the parameter
        typeName,
        // Name of the Parameter
        name,
        // Default value for the parameter
        default
    }[],
    // The format of the results
    results:{
        // The Id of the type of the result
        typeId,
        // The name of the Type of the result
        typeName,
        // The name of the result
        name
    }[]
}