Giter Club home page Giter Club logo

easyport-node-d2xx's Introduction

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

* 

easyport-node-d2xx's People

Contributors

calumk avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.