npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@calumk/easyport-node-d2xx

v0.0.4

Published

Cross Platform Library for using EasyPort in Node.js

Downloads

10

Readme

easyport-node-d2xx

Cross Platform Library for using EasyPort in Node.js

https://ip.festo-didactic.com/InfoPortal/MPS/EasyPort/EN/index.html

Description

EasyPort is a GPIO device designed and manufactured by Festo Didactic, for connection to Festo Products using Syslink or Sub-D Connectors.

This library is designed to be cross-platform (osx/windows/linux) way to read & write data from the Easyport.

It will also form the basis for another project -> @calumk/easyport-webusb

[!NOTE] This specific library uses FTDI-D2XX library.

This Library does NOT require the ActiveX Driver from Festo Didactic - This is a "standalone" re-implemmentation

[!IMPORTANT] This library is designed for educational purposes, and should not be used for saftey-critical systems.

[!TIP] At the moment, Only Digital is supported. Analog will be supported soon.


## Simple Use

This outlines simple use of the library

Setup

import { EasyPort } from "@calumk/easyport-node-d2xx";

let easyport = new EasyPort({
    timeouts : {
        tx : 100,
        rx : 100
    }
});

// List all Devices
let devices = easyport.getDevices()
console.log(devices)

await easyport.openDevice(0);

Reading Bits / Bytes / Words

// Read A single Bit (defaults to 0)
let example1 = await easyport.read_input_bit()
console.log(example1);

// Read A single Bit (Bit 4)
let example2 = await easyport.read_input_bit({
  bit : 4
})
console.log(example2);


// Read A single Byte (defaults to 0) = (Port 0)
let example3 = await easyport.read_input_byte()
console.log(example3);

// Read A single Byte (Byte 1) =  (Port 1)
let example4 = await easyport.read_input_byte({
  byte : 1
})
console.log(example4);

// Read the input word (There are multiple, but only 1 worth reading because this is Port 1 + Port 2)
let respons3 = await easyport.read_input_word()
console.log(respons3);

Writing Bits / Bytes / Words

// Turn on the first bit
await easyport.write_output_bit({
  bit : 0
  value : 1
})

// Turn on Bits 1 + 2 + 3 = 7 (Binary)
await easyport.write_output_byte({
  byte : 0,
  value : 7
})

// Turn on all bits (Binary)
await easyport.write_output_byte({
  value : 65535
})

Advanced Use [BETA]

It is possible to enable monitoring mode, this is useful if you MAINLY want to read data, very quickly. < (25ms)

In monitoring mode, if you want to "WRITE" data again, you currently need to stop the monitoring mode This is to prevent data collision, as otherwise you can end up reading data from the monitor mode instead of the response to your own command.

To accomplish this, the library will automatically disable monitoring mode, and then re-enable it once the write is complete, but this means that it takes time (50ms) to switch modes. So if you want to read + write data fast - its probably easier to just do it cyclicly with a setInterval for now.

This is not very performant, and it is possible that it is unnessesary - more work to consider.


// Enable the Monitoring Mode
easyport.enableMonitoringMode()

// disable Monitoring Mode
easyport.disableMonitoringMode()

// this will tell you when the monitoring mode has changed
// This is useful, because if you try to write data while monitoring mode is on, it will be automatically disabled, and then re-endabled.
easyport.registerNewMonitoringModeEnabledListener((data) => {
    console.log("Monitoring Mode: ", data)
});

// This will log all monitored data (the value of the whole word 0)
easyport.registerNewMonitoringModeListener((data) => {
    console.log(data)
});




## Requirements
* ftdi-d2xx

*