@@ -241,12 +241,13 @@ To add a new serial device, you must add an object to
241241 setTimeout ( writeChunk , 50 ) ;
242242 return ;
243243 }
244- var chunk ;
245- if ( ! connection . txDataQueue . length ) {
244+ if ( ! connection . txDataQueue . length ) { // we're finished!
245+ connection . txInProgress = false ;
246246 connection . updateProgress ( ) ;
247247 return ;
248248 }
249- var txItem = connection . txDataQueue [ 0 ] ;
249+ connection . txInProgress = true ;
250+ var chunk , txItem = connection . txDataQueue [ 0 ] ;
250251 connection . updateProgress ( txItem . maxLength - ( txItem . data ?txItem . data . length :0 ) , txItem . maxLength ) ;
251252 if ( txItem . data . length <= connection . chunkSize ) {
252253 chunk = txItem . data ;
@@ -255,7 +256,6 @@ To add a new serial device, you must add an object to
255256 chunk = txItem . data . substr ( 0 , connection . chunkSize ) ;
256257 txItem . data = txItem . data . substr ( connection . chunkSize ) ;
257258 }
258- connection . txInProgress = true ;
259259 log ( 2 , "Sending " + JSON . stringify ( chunk ) ) ;
260260 connection . writeLowLevel ( chunk ) . then ( function ( ) {
261261 log ( 3 , "Sent" ) ;
@@ -269,7 +269,6 @@ To add a new serial device, you must add an object to
269269 }
270270 if ( ! ( promise instanceof Promise ) )
271271 promise = Promise . resolve ( ) ;
272- connection . txInProgress = false ;
273272 promise . then ( writeChunk ) ; // if txItem.callback() returned a promise, wait until it completes before continuing
274273 } , function ( error ) {
275274 log ( 1 , 'SEND ERROR: ' + error ) ;
0 commit comments