A TypeScript/JavaScript API for controlling Hilscher CIFX cards.
This package provides a simple interface for communicating with Hilscher CIFX cards in Node.js. It enables sending and receiving process data as well as managing the cards via a modern API.
- ⚡ Easy initialization and management of CIFX cards
- 🔄 Send and receive IO data
- 🧩 Support for multiple cards and channels
- 🛡️ Includes TypeScript type definitions
Note: This package requires cifx drivers to be installed.
More information can be found in the Hilscher documentation.
npm install jscifxStatic class for initializing, deinitializing, and managing the CifX driver. Ensures the driver is set up before use and provides access to the Driver class.
Main Methods:
CifX.init(): Initializes the driver. Throws if already initialized.CifX.deinit(): Deinitializes the driver. Throws if not initialized.CifX.openDriver(): Opens the driver and returns aDriverinstance.CifX.initialized: Returnstrueif the driver is initialized.
Example:
import {CifX} from "jscifx";
CifX.init();
const driver = CifX.openDriver();
// ... use driver
driver.close();
CifX.deinit();Represents an open handle to the CifX driver. Allows querying driver information and enumerating connected boards.
Main Methods & Properties:
driver.version: Returns the driver version string.driver.boardCount: Number of available boards.driver.getBoard(index): Returns aBoardinstance for the given index.driver.enumerateBoards(): Generator to iterate over all boards.driver.close(): Closes the driver handle.
Example:
for (const board of driver.enumerateBoards()) {
console.log(board.name);
}Represents a hardware board managed by the driver. Provides access to board information and its communication channels.
Main Methods & Properties:
board.name: Name of the board.board.channelCount: Number of channels on the board.board.getChannel(index): Returns aChannelinstance.board.enumerateChannels(): Generator to iterate over all channels.
Example:
const board = driver.getBoard(0);
for (const channel of board.enumerateChannels()) {
console.log(channel.firmware);
}Represents a communication channel on a board. Supports opening/closing, managing bus/host state, and I/O operations.
Main Methods & Properties:
channel.open() / channel.close(): Open/close the channel.channel.openBus() / channel.closeBus(): Open/close the bus for communication.channel.startHost() / channel.stopHost(): Set host state.channel.ioWrite(area, offset, data, timeout?): Write data to I/O area.channel.ioRead(area, offset, length, timeout?): Read data from I/O area.channel.firmware: Firmware name of the channel.
Example:
const channel = board.getChannel(0);
channel.open();
channel.startHost();
channel.openBus();
channel.ioWrite(0, 0, Buffer.from([1, 2, 3]));
const data = channel.ioRead(0, 0, 3);
channel.closeBus();
channel.stopHost();
channel.close();General Notes:
- Always call
CifX.init()before using any driver functionality andCifX.deinit()when done. - Use try/catch to handle
CifXErrorexceptions. - The API is synchronous and throws on errors.
- All resources (driver, channels) should be closed after use to avoid leaks.
If you have questions or issues, please open an issue.