You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing a port to the Avrgirl class, ideally, that port should be ready for use once the callback passed to avrgirl.flash() is triggered. That allows clients to immediately use the port after a flash without adding some arbitrary wait time.
Expected behaviour
The port passed to the Avrgirl constructor is free and available for other services to connect to once avrgirl.flash() has finished.
Actual behaviour
avrgirl-arduino instantiates a new port connection.serialPort which can sometimes still be in use by the time the callback in flash() has been entered. This prevented accessing that port immediately.
Operating system and version
Win 10 - November 2021 Update
Could not reproduce on Ubuntu 20.04.4 LTS (Focal Fossa)
Avrgirl Arduino version
5.0.1
NodeJS version
14.18.3
Arduino Board being used
ATmega1284p
Log output, if available
Step by step guide to reproducing the issue
awaitnewPromise<boolean>((resolve,reject)=>{this._avrgirl.flash(path,(err: Error)=>{if(err){reject(err);}else{resolve(true);}});});constp=newSerialPort(<portpath>);p.open((err)=>{// results in ACCESS DENIED error because the `avrgirl.connection.serialPort` is still open});
Workaround - wait for connection.serialPort to close before trying to access the port
publicasyncflash(path: string): Promise<boolean>{const flashComplete =newPromise<boolean>((resolve,reject)=>{this._avrgirl.flash(path,(err: Error)=>{if(err){reject(err);}else{resolve(true);}});});// Need to ensure the device that AVR girl created is closedconstportClosed=newPromise<boolean>((resolve,reject)=>{this._avrgirl.connection.serialPort.on('close',(err)=>{if(err){reject(err);}else{resolve(true);}});});constdeviceReady=awaitPromise.all([portClosed,flashComplete]);returndeviceReady[0]&&deviceReady[1];}
The text was updated successfully, but these errors were encountered:
Description
When passing a port to the
Avrgirl
class, ideally, that port should be ready for use once the callback passed toavrgirl.flash()
is triggered. That allows clients to immediately use the port after a flash without adding some arbitrary wait time.Expected behaviour
The port passed to the
Avrgirl
constructor is free and available for other services to connect to onceavrgirl.flash()
has finished.Actual behaviour
avrgirl-arduino instantiates a new port
connection.serialPort
which can sometimes still be in use by the time the callback inflash()
has been entered. This prevented accessing that port immediately.Operating system and version
Win 10 - November 2021 Update
Could not reproduce on Ubuntu 20.04.4 LTS (Focal Fossa)
Avrgirl Arduino version
5.0.1
NodeJS version
14.18.3
Arduino Board being used
ATmega1284p
Log output, if available
Step by step guide to reproducing the issue
Workaround - wait for connection.serialPort to close before trying to access the port
The text was updated successfully, but these errors were encountered: