UNPKG

dynamixel

Version:

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

101 lines (100 loc) 3.27 kB
/** * Web Serial API Connection Handler * For use in Electron renderer processes and modern browsers */ export class WebSerialConnection extends EventEmitter<[never]> { /** * Get available serial ports (previously authorized) * @returns {Promise<Array>} - Array of port info objects */ static getAvailablePorts(): Promise<any[]>; /** * Check if Web Serial API is supported * @returns {boolean} - Support status */ static isSupported(): boolean; /** * Get Web Serial API feature detection info * @returns {Object} - Feature support information */ static getFeatureSupport(): Object; constructor(options?: {}); port: any; reader: any; writer: any; timeout: any; baudRate: any; isConnected: boolean; receiveBuffer: Uint8Array<ArrayBuffer>; readPromise: Promise<void> | null; /** * Request and connect to a serial port using Web Serial API * @param {Object} filters - Optional filters for port selection * @returns {Promise<boolean>} - Success status */ connect(filters?: Object): Promise<boolean>; /** * Connect to a previously authorized port (if available) * @returns {Promise<boolean>} - Success status */ connectToPreviousPort(): Promise<boolean>; /** * Disconnect from the serial port */ disconnect(): Promise<void>; /** * Start receiving data from the serial port */ startReceiving(): Promise<void>; /** * Main read loop for processing incoming data */ readLoop(): Promise<void>; /** * Process received data buffer for complete packets */ processReceiveBuffer(): void; /** * Send data to the serial port * @param {Buffer|Uint8Array} data - Data to send * @returns {Promise<boolean>} - Success status */ send(data: Buffer | Uint8Array): Promise<boolean>; /** * Send instruction packet and wait for response * @param {Buffer} packet - Instruction packet to send * @param {number} expectedId - Expected response ID (null for any) * @param {number} timeout - Timeout in milliseconds * @returns {Promise<Object>} - Parsed status packet */ sendAndWaitForResponse(packet: Buffer, expectedId?: number, timeout?: number): Promise<Object>; /** * Ping a specific DYNAMIXEL device * @param {number} id - DYNAMIXEL ID * @param {number} timeout - Timeout in milliseconds * @returns {Promise<Object>} - Device information */ ping(id: number, timeout?: number): Promise<Object>; /** * Discover all DYNAMIXEL devices on the bus * @param {Object} options - Discovery options * @returns {Promise<Array>} - Array of discovered devices */ discoverDevices(options?: Object): Promise<any[]>; /** * Set baud rate for serial communication * @param {number} baudRate - New baud rate */ setBaudRate(baudRate: number): void; /** * Get current baud rate * @returns {number} - Current baud rate */ getBaudRate(): number; /** * Get connection status * @returns {boolean} - Connection status */ getConnectionStatus(): boolean; } import { EventEmitter } from 'events';