App-ArduinoBuilder
view release on metacpan or search on metacpan
lib/App/ArduinoBuilder.pm view on Meta::CPAN
info 'Using the first match port from the configuration: %s', $port->get('upload.port.address');
$config->set('builder.internal.selected_port' => $port);
return $port;
}
sub upload {
my ($config) = @_;
info 'Uploading binary to the board...';
my $port = select_port($config);
my $protocol = $port->get('upload.port.protocol');
my $tool = $config->get("upload.tool.${protocol}", default => $config->get('upload.tool.default', default => $config->get('upload.tool')));
my $tool_config = $config->filter("tools.${tool}");
# TODO: add a way to set the verbose mode, in which case the upload.params.verbose
# property should be copied, instead of upload.params.quiet.
# Reference: https://arduino.github.io/arduino-cli/0.32/platform-specification/#verbose-parameter
$tool_config->set('upload.verbose' => $tool_config->get('upload.params.quiet'), allow_override => 1);
my $upload_config = $config->filter("upload.${protocol}")->prefix('upload');
$upload_config->merge($tool_config);
$upload_config->merge($port);
# Note: $config is in the recursive base in $upload_config.
# TODO: Before executing the command, some boards require that we manually
# reset them through their Serial port.
# See the code: https://github.com/arduino/arduino-cli/blob/ad9ddb882016c2af10e0db3785a46122bc9cfb1f/commands/upload/upload.go#L370
# And the doc: https://arduino.github.io/arduino-cli/0.32/platform-specification/#1200-bps-bootloader-reset
my $cmd = $upload_config->get('upload.pattern');
debug "Upload configuration:\n%s", sub { $upload_config->dump(' ') };
default_executor()->run_now(sub {
close STDIN;
execute_cmd($cmd);
});
info 'Success!';
}
sub monitor {
my ($config) = @_;
info 'Running board monitor. Press ctrl+c to exit...';
my $port = select_port($config);
App::ArduinoBuilder::Monitor::monitor($config, $port);
info 'Success!';
}
1;
__DATA__
@@ log4perl.conf
# We send all messages to two appenders (one that prints the level and the
# other that does not). But they have each a LevelMatch filter attached so
# that each message is eventually only printed once.
# This is so that frequent message (below the INFO level) are printed without
# their level to increase readability (especially for command lines). More
# serious messages are displayed with their level.
#
# All of that can be configured with the --logconf flag.
#
# Remember that we have a custom log level.
#
# The default log level itself is set to a default here but can be configured
# later too.
log4perl.rootLogger = INFO, ScreenWithLevel, ScreenWithoutLevel
# Configuration of the ScreenWithLevel appender for the levels INFO to
# FATAL.
log4perl.appender.ScreenWithLevel = Log::Log4perl::Appender::Screen
log4perl.appender.ScreenWithLevel.layout = PatternLayout
log4perl.appender.ScreenWithLevel.layout.ConversionPattern = %p: %m%n
log4perl.appender.ScreenWithLevel.Filter = InfoToFatalFilter
log4perl.filter.InfoToFatalFilter = Log::Log4perl::Filter::LevelRange
log4perl.filter.InfoToFatalFilter.LevelMin = INFO
log4perl.filter.InfoToFatalFilter.LevelMax = FATAL
log4perl.filter.InfoToFatalFilter.AcceptOnMatch = true
# Configuration of the ScreenWithoutLevel appender for the levels levels below
# INFO.
log4perl.appender.ScreenWithoutLevel = Log::Log4perl::Appender::Screen
log4perl.appender.ScreenWithoutLevel.layout = PatternLayout
log4perl.appender.ScreenWithoutLevel.layout.ConversionPattern = %m%n
log4perl.appender.ScreenWithoutLevel.Filter = DebugFilter
# We just define this filter as the complement of the other one, to be sure not
# to loose any message.
log4perl.filter.DebugFilter = Log::Log4perl::Filter::LevelRange
log4perl.filter.DebugFilter.LevelMin = INFO
log4perl.filter.DebugFilter.LevelMax = FATAL
log4perl.filter.DebugFilter.AcceptOnMatch = false
log4perl.oneMessagePerAppender = 1
( run in 0.636 second using v1.01-cache-2.11-cpan-e1769b4cff6 )