@@ -358,14 +358,14 @@ class G2coreAPI extends EventEmitter {
358358 // See https://github.com/synthetos/TinyG/wiki/TinyG-Status-Codes#status-report-enumerations
359359 // for more into about stat codes.
360360
361- // 3 program stop or no more blocks (M0, M1, M60)
362- // 4 program end via M2, M30
361+ // 3 program stop or no more blocks (M0, M1, M60)
362+ // 4 program end via M2, M30
363363 if ( sr . stat == 3 || sr . stat == 4 ) {
364364 // if (this.doneSending) {
365365 // this.emit('doneSending');
366366 // }
367367
368- // 2 machine is in alarm state (shut down)
368+ // 2 machine is in alarm state (shut down)
369369 } else if ( sr . stat == 2 ) {
370370 // Fatal error! Shut down!
371371 // this.emit('doneSending', sr);
@@ -611,15 +611,15 @@ class G2coreAPI extends EventEmitter {
611611 this . ignoredResponses ++ ;
612612 }
613613 this . _write ( value ) ;
614-
615- // handle flush command
616- if ( typeof value === 'string' && value . match ( / % + / ) ) {
617- this . _resetLinesRequested ( ) ;
618- this . linesSent = 0 ;
619- this . ignoredResponses = 0 ;
620- this . lineBuffer . length = 0 ;
621- }
622-
614+
615+ // handle flush command
616+ if ( typeof value === 'string' && value . match ( / % + / ) ) {
617+ this . _resetLinesRequested ( ) ;
618+ this . linesSent = 0 ;
619+ this . ignoredResponses = 0 ;
620+ this . lineBuffer . length = 0 ;
621+ }
622+
623623 return ;
624624 }
625625
@@ -902,8 +902,8 @@ class G2coreAPI extends EventEmitter {
902902 if ( sr . stat ) {
903903 // console.log("sr.stat: " + this.lineCountToSend)
904904
905- // 3 program stop or no more blocks (M0, M1, M60)
906- // 4 program end via M2, M30
905+ // 3 program stop or no more blocks (M0, M1, M60)
906+ // 4 program end via M2, M30
907907 if ( sr . stat == 3 || sr . stat == 4 ) {
908908 if ( sr . stat == 4 ) {
909909 if ( fileEnded && doneSending ) {
@@ -912,7 +912,7 @@ class G2coreAPI extends EventEmitter {
912912 stopOrEndStat = true ;
913913 }
914914
915- // 2 machine is in alarm state (shut down)
915+ // 2 machine is in alarm state (shut down)
916916 } else if ( sr . stat == 2 ) {
917917 // If the machine is in error, we're done no matter what
918918 if ( ! this . timedSendsOnly ) {
@@ -1206,20 +1206,27 @@ class G2coreAPI extends EventEmitter {
12061206
12071207 for ( let i = 0 ; i < results . length ; i ++ ) {
12081208 let item = results [ i ] ;
1209+ let x ;
12091210
12101211 if ( process . platform === 'win32' ) {
12111212 // Windows:
12121213 // pnpId: USB\VID_1D50&PID_606D&MI_00\6&3B3CEA53&0&0000
12131214 // pnpId: USB\VID_1D50&PID_606D&MI_02\6&3B3CEA53&0&0002
1215+ // pnpId: USB\VID_1D50&PID_606D\0084-D639-0084-08C6
12141216
12151217 // WARNING -- explicit test against VIP/PID combo.
1216- if ( ( x = item . pnpId . match ( / ^ U S B \\ V I D _ ( [ 0 - 9 A - F a - f ] + ) & P I D _ ( [ 0 - 9 A - F a - f ] + ) & M I _ ( [ 0 - 9 ] + ) \\ ( .* ) $ / ) ) && // eslint-disable-line
1218+ if ( ( x = item . pnpId . match ( / ^ U S B \\ V I D _ ( [ 0 - 9 A - F a - f ] + ) & P I D _ ( [ 0 - 9 A - F a - f ] + ) (?: (?: & M I _ ( [ 0 - 9 ] + ) \\ ( .* ) ) | (?: \\ ( . * ) ) ) $ / ) ) && // eslint-disable-line
12171219 ( x [ 1 ] == '1D50' ) && ( x [ 2 ] == '606D' )
12181220 ) {
1221+ let serialNumber ;
12191222 // let vendor = x[1]; // never used
12201223 // let pid = x[2]; // never used
1221- let theRest = x [ 4 ] . split ( '&' ) ;
1222- let serialNumber = theRest [ 1 ] ;
1224+ if ( x [ 4 ] ) {
1225+ let theRest = x [ 4 ] . split ( '&' ) ;
1226+ serialNumber = theRest [ 1 ] ;
1227+ } else {
1228+ serialNumber = x [ 5 ] ;
1229+ }
12231230
12241231 if (
12251232 ( g2s . length > 0 ) &&
0 commit comments