Skip to content

Fix panic when board attach args are incomplete #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

masci
Copy link
Contributor

@masci masci commented Aug 16, 2019

Fixes #165

The command board attach was configured to optionally take only one argument (the FQBN) but it's actually missing any logic to fill the gap (figuring out sketch name and path) when a sketch is not passed.

This PR enforces the sketch to be passed and fixes the command documentation accordingly.

@cmaglie
Copy link
Member

cmaglie commented Aug 16, 2019

The intended behaviour is to use the current folder if the sketch path is not specified (and I remember it worked in the past, this is surely a regression that was introduced during the GRPC implementation).

Other commands with the same behaviour:

https://github.com/arduino/arduino-cli/blob/master/cli/compile/compile.go#L82
https://github.com/arduino/arduino-cli/blob/master/cli/upload/upload.go#L65

also... this code is duplicated, it may be worth it to create a shortcut to avoid copying it everywhere :-)

@masci
Copy link
Contributor Author

masci commented Aug 16, 2019

Ok for the path but what the sketch name should be? (Also one might argue why the current folder and not the sketchbook).

I didn't know there were other commands following this pattern but if I got right how we want the behaviour of sketch new to be, this will clash with what we're assuming here, which is "when nothing is provided, assume current folder and xxx as name".

As a side note, from the UX perspective I think any command requiring a sketch should be provided in input with a sketch name (so I can look in the sketchbook) or sketch path (so I can look in the fs).

@cmaglie
Copy link
Member

cmaglie commented Aug 16, 2019

Ok for the path but what the sketch name should be? (Also one might argue why the current folder and not the sketchbook).

In this case the name of the sketch will be exactly the same of the parent directory (i.e. if the current directory is ~/workspace/mysketch the sketch name will be mysketch. This should be also validated by checking the existence of ~/workspace/mysketch/mysketch.ino.

but if I got right how we want the behaviour of sketch new to be, this will clash with what we're assuming here

Yes, I expressed exactly this concern in the JIRA task.

from the UX perspective I think any command requiring a sketch should be provided in input with a sketch name (so I can look in the sketchbook) or sketch path (so I can look in the fs).

don't underestimate how handy can be omitting the sketch path or the sketch name, instead of

arduino-cli compile -b arduino:avr:uno sketch
arduino-cli upload -p /dev/ttyACM0 -b arduino:avr:uno sketch

you can do:

arduino-cli compile -b arduino:avr:uno
arduino-cli upload -p /dev/ttyACM0 -b arduino:avr:uno

or even (after board attach-ing):

arduino-cli compile
arduino-cli upload

@masci
Copy link
Contributor Author

masci commented Aug 19, 2019

Closing as this doesn't solve the root issue.

@masci masci closed this Aug 19, 2019
@masci masci deleted the massi/165 branch August 19, 2019 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGSEGV running 'board attach' with fqbn in 0.3.6-alpha.preview
2 participants