Serial/src/models/serial.js
/**
     * Opens a port with comName and adds it to the parsers
     * @param comName
     * @returns {Promise<void|err>}
     */
Opens a port with comName and adds it to the parsers
@param comName
@returns {Promise}
Opens a port with comName and adds it to the parsers @param comName @returns { Promise }
async openPort(comName) {
        return new Promise(async (resolve, reject) => {
            for(let i=0; i<this.loadedPorts.length; i++) {
                if(this.loadedPorts[i].path !== comName) continue;
                if(this.loadedPorts[i].isOpen) return reject("Port is already open");
                return this.loadedPorts[i].open((e) => {
                    if(e) return reject(new Error(e));
                    let parser = this.loadedPorts[i].pipe(new serialPort.parsers.Readline({ delimiter: '\r\n' }));
                    parser.comName = comName;
                    this.parsers.push(parser);
                    return resolve();
                });
            }
            return reject("Port does not exist!");
        });
    }
async openPort ( comName ) { return new Promise ( async ( resolve , reject ) => { for ( let i = 0 ; i < this . loadedPorts . length ; i ++ ) { if ( this . loadedPorts [ i ] . path !== comName ) continue ; if ( this . loadedPorts [ i ] . isOpen ) return reject ( "Port is already open" ) ; return this . loadedPorts [ i ] . open ( ( e ) => { if ( e ) return reject ( new Error ( e ) ) ; let parser = this . loadedPorts [ i ] . pipe ( new serialPort . parsers . Readline ( { delimiter : '\r\n' } ) ) ; parser . comName = comName ; this . parsers . push ( parser ) ; return resolve ( ) ; } ) ; } return reject ( "Port does not exist!" ) ; } ) ; }
Opens a port with comName and adds it to the parsers
 @param comName
 @returns {Promise<void|err>}
Opens a port with comName and adds it to the parsers @param comName @returns { Promise<void|err > }