UNPKG

dynamixel

Version:

Node.js library for controlling DYNAMIXEL servo motors via U2D2 interface with Protocol 2.0 support

90 lines (89 loc) 2.76 kB
/** * Node.js SerialPort Connection Handler (ES Module version) * For use in Node.js environments and Electron main process */ export class SerialConnection extends EventEmitter<[never]> { /** * List available serial ports * @returns {Promise<Array>} - Array of available ports */ static listSerialPorts(): Promise<any[]>; /** * Check if SerialPort is available * @returns {boolean} - True if available */ static isAvailable(): boolean; /** * Get SerialPort module information * @returns {Object} - Module information */ static getModuleInfo(): Object; constructor(options?: {}); port: any; timeout: any; baudRate: any; isConnected: boolean; receiveBuffer: Buffer<ArrayBuffer>; portPath: any; /** * Find and connect to U2D2 device via serial port * @param {string} portPath - Optional specific port path * @returns {Promise<boolean>} - Success status */ connect(portPath?: string): Promise<boolean>; /** * Find U2D2 device port automatically * @returns {Promise<string|null>} - Port path or null if not found */ findU2D2Port(): Promise<string | null>; /** * Disconnect from serial port */ disconnect(): Promise<void>; /** * Process received data buffer */ processReceiveBuffer(): void; /** * Send data to the device * @param {Buffer|Array} data - Data to send */ send(data: Buffer | any[]): Promise<any>; /** * Send packet and wait for response * @param {Buffer} packet - Packet to send * @param {number} expectedId - Expected device ID in response * @param {number} timeout - Timeout in milliseconds * @returns {Promise<Buffer>} - Response packet */ sendAndWaitForResponse(packet: Buffer, expectedId?: number, timeout?: number): Promise<Buffer>; /** * Ping a device * @param {number} id - Device ID * @param {number} timeout - Timeout in milliseconds * @returns {Promise<Object>} - Ping response */ ping(id: number, timeout?: number): Promise<Object>; /** * Discover devices on the bus * @param {Object} options - Discovery options * @returns {Promise<Array>} - Array of discovered devices */ discoverDevices(options?: Object): Promise<any[]>; /** * Set baud rate * @param {number} baudRate - Baud rate */ setBaudRate(baudRate: number): void; /** * Get current baud rate * @returns {number} - Current baud rate */ getBaudRate(): number; /** * Get connection status * @returns {Object} - Connection status */ getConnectionStatus(): Object; } import { EventEmitter } from 'events';