_sendAndRegisterForResponse(reqBuffer, responseType) {
        if (!this.socket) {
            return Promise.reject(new Error('Device not connected'));
        }

        if (this.expectedResponsePromises[responseType]) {
            return this.expectedResponsePromises[responseType].responsePromise;
        }

        debug(`Write and register for response type ${responseType}: ${reqBuffer.toString('hex')}`);
        this.socket.write(reqBuffer);

        const responsePromise = getDeferredPromise();

        this.expectedResponsePromises[responseType] = {
            responseType,
            responsePromise,
            responseTimeout: setTimeout(() => {
                if (this.expectedResponsePromises[responseType]) {
                    debug(`Reject registered responses for response type ${responseType}`);
                    this.expectedResponsePromises[responseType].responsePromise.reject();
                    delete this.expectedResponsePromises[responseType];
                }
            }, this.options.responseTimeout || RESPONSE_TIMEOUT)
        };
        return responsePromise;
    }
/**
     * Sends a command to the device and registers a promise to be resolved when response was received
     *
     * @param {Buffer} reqBuffer Request Buffer to send out
     * @param {number} responseType Expected Message type from device for response
     * @returns {Promise<*>} Promise that resolves on response
     * @private
     */
Sends a command to the device and registers a promise to be resolved when response was received
@param {Buffer} reqBuffer Request Buffer to send out
@param {number} responseType Expected Message type from device for response
@returns {Promise<*>} Promise that resolves on response
@private
Sends a command to the device and registers a promise to be resolved when response was received @param { Buffer } reqBuffer Request Buffer to send out @param { number } responseType Expected Message type from device for response @returns { Promise< * > } Promise that resolves on response @private
_sendAndRegisterForResponse(reqBuffer, responseType) {
        if (!this.socket) {
            return Promise.reject(new Error('Device not connected'));
        }
        if (this.expectedResponsePromises[responseType]) {
            return this.expectedResponsePromises[responseType].responsePromise;
        }
        debug(`Write and register for response type ${responseType}: ${reqBuffer.toString('hex')}`);
        this.socket.write(reqBuffer);
        const responsePromise = getDeferredPromise();
        this.expectedResponsePromises[responseType] = {
            responseType,
            responsePromise,
            responseTimeout: setTimeout(() => {
                if (this.expectedResponsePromises[responseType]) {
                    debug(`Reject registered responses for response type ${responseType}`);
                    this.expectedResponsePromises[responseType].responsePromise.reject();
                    delete this.expectedResponsePromises[responseType];
                }
            }, this.options.responseTimeout || RESPONSE_TIMEOUT)
        };
        return responsePromise;
    }
_sendAndRegisterForResponse ( reqBuffer , responseType ) { if ( ! this . socket ) { return Promise . reject ( new Error ( 'Device not connected' ) ) ; } if ( this . expectedResponsePromises [ responseType ] ) { return this . expectedResponsePromises [ responseType ] . responsePromise ; } debug ( ` ${ responseType } ${ reqBuffer . toString ( 'hex' ) } ` ) ; this . socket . write ( reqBuffer ) ; const responsePromise = getDeferredPromise ( ) ; this . expectedResponsePromises [ responseType ] = { responseType , responsePromise , responseTimeout : setTimeout ( ( ) => { if ( this . expectedResponsePromises [ responseType ] ) { debug ( ` ${ responseType } ` ) ; this . expectedResponsePromises [ responseType ] . responsePromise . reject ( ) ; delete this . expectedResponsePromises [ responseType ] ; } } , this . options . responseTimeout || RESPONSE_TIMEOUT ) } ; return responsePromise ; }
Sends a command to the device and registers a promise to be resolved when response was received
 @param {Buffer} reqBuffer Request Buffer to send out
 @param {number} responseType Expected Message type from device for response
 @returns {Promise<*>} Promise that resolves on response
 @private
Sends a command to the device and registers a promise to be resolved when response was received @param { Buffer } reqBuffer Request Buffer to send out @param { number } responseType Expected Message type from device for response @returns { Promise< * > } Promise that resolves on response @private