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
Rewrite ard-leonardo-reset script in perl #62
Comments
Without a Leonardo to test with I can't be sure, but if someone could test this, we could prettyify it with helptext/argument passing etc. Also it doesn't hang my serial port afterwards (on mega) so I assume wait-connection-leonardo would no longer be required (have to test that on a real Leo though, as it does weird virtual device create/destroy when booting). #!/usr/bin/env perl
use strict;
use warnings;
use Device::SerialPort;
my $port = Device::SerialPort->new('/dev/ttyACM0'); # open port
$port->baudrate(1200); # set baud
$port->write_settings; # restart with new baud
$port->close; # close port |
Thanks. I will test it when I get back home today, in a couple of hours. |
I tested the above code with Leonardo and it is working. On second thought, I was thinking whether it will make sense to pass a extra parameter to bin/ard-reset-arduino perl script itself and have this code there. One less file to manage. Also at a later point if Arduino comes with a new board we can modify one perl script itself, instead of creating multiple files. What are your thoughts? |
yes i think it is worth merging the two, i'll have a go at it soon. oh did you check that the serial port didn't disappear after the reset - which is what the wait-connection-leonardo script fixes? it'd be nice to reduce 3 scripts down to 1. |
Cool. Thanks 👍
Yes it does disappear. I did a quick search and it seems to be an expected behavior http://arduino.cc/en/Guide/ArduinoLeonardo#toc3 |
yes but it should come back after a second or so, having to pull the cable is a bit naff. |
could you test my commit bed0fd4 with your Leonardo please? i've made it backwards-compatible so no change is required for the arduino to reset. not a lot of changes required actually, most of the commit is whitespace fixes! oddly enough either leonardo or arduino method resets my Boarduino! $ make reset
-------------------------
Arduino.mk Configuration:
- [USER] ARDUINO_DIR = /usr/share/arduino
- [AUTODETECTED] ARDUINO_VERSION = 105
- [USER] AVR_TOOLS_DIR = /usr
- [COMPUTED] ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [COMPUTED] ARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino/variants (from ARDUINO_DIR)
- [USER] ARDMK_DIR = /usr
- [USER] ARDMK_PATH = /data7/useful_software/arduino/arduino-mk/my_git/Arduino-Makefile/bin
- ARDUINO_SKETCHBOOK = /home/simon/programming/c++/arduino
- [DEFAULT] USER_LIB_PATH = /home/simon/programming/c++/arduino/libraries (in user sketchbook)
- [USER] BOARD_TAG = leonardo
- [DETECTED] MONITOR_BAUDRATE = 9600 (in sketch)
- [AUTODETECTED] Size utility: AVR-aware for enhanced output
-
- ARDUINO_LIBS =
- [USER] LCD
- [SYSTEM] Wire
- [SYSTEM] Wire/utility
- [SYSTEM] Wire/utility
-------------------------
Resetting Arduino...
/data7/useful_software/arduino/arduino-mk/my_git/Arduino-Makefile/bin/ard-reset-arduino --leonardo /dev/ttyUSB0
/data7/useful_software/arduino/arduino-mk/my_git/Arduino-Makefile/bin/wait-connection-leonardo /dev/ttyUSB0
Connection Established
|
I just tested it in Leonardo and it works. But out of 10+ times, it failed for about 1-2 times. I guess this is because of the timing issue.
If for some reason, avrdude is not able to send the first request, within 8 seconds, then the processor starts to execute user code and the upload fails. But this happens very rarely. I guess we can do only so much. Even when the upload fails, if I press the RESET button in the board, then the upload works properly.
I tested with Uno as well and it works perfectly. Can I go ahead and merge this, or do you want to do any more changes/cleanup? |
you can merge it sure, as i don't think it is any worse than the python script as far as the timing issue goes - that's what wait-connection-leonardo is supposed to handle. after some googling, it seems nobody (even the IDE) has a 100% reliable setup here, mainly due to the computer handling disappearing USB devices than the Leo itself. moved it to a pull request which merges into your upstream fine (with the #70 libs dir fix) to make it easier for you. |
Right now the bin/ard-leonardo-reset script is in Python. All the other scripts are in perl, so it would be nice to rewrite this in perl as well.
My perl skills are not that good. It would be nice if someone with better perl skills than mine does this.
The text was updated successfully, but these errors were encountered: