Arduino CLI
1 Zkouším arduino-cli
Chci mít možnost kompilovat *.ino ze skriptu a sdílet knihovny
Nějak jsem nainstaloval arduino a arduino-cli a něco někde oklikal ... * asi jako root curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh * a jako user arduino-cli core install arduino:avr * arduino-cli core update-index
cat ~/bin/ac #!/bin/bash -x # vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:syntax=sh:filetype=sh:ruler:showcmd:lcs=tab\:|- list arduino-cli --config-file .config.yaml "$@"
ta @#$% vyžaduje, aby ten soubor končil na .yaml i když ho výslovně uvedu jménem
a v defaultu má metrics povolené
a zkusím, jestli půjde použít i z aktuálního adresáře
$ ac board list + arduino-cli --config-file .config.yaml board list Port Protocol Type Board Name FQBN Core /dev/ttyACM0 serial Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega arduino:avr $ ac compile --fqbn arduino:avr:mega MyFirstSketch $ ac upload -p /dev/ttyACM0 --fqbn arduino:avr:mega MyFirstSketch
vypadá to, že to základně funguje, teď ještě knihovny ...
nový .config.yaml - user: . enable_notification: false metrics: enabled: false
$ cat .config.yaml board_manager: additional_urls: [] build_cache: compilations_before_purge: 10 ttl: 720h0m0s daemon: port: XXXXXXXXXXX directories: data: /home/gilhad/.arduino15 downloads: /home/gilhad/.arduino15/staging user: . library: enable_unsafe_install: false logging: file: "" format: text level: info metrics: addr: XXXXXXXXX enabled: false output: no_color: false sketch: always_export_binaries: false updater: enable_notification: false
a Makefile (LIBS = ../libs)
#!/bin/bash # vim: fileencoding=utf-8:nomodified:nowrap:textwidth=0:foldmethod=marker:foldcolumn=4:syntax=make:filetype=make:ruler:showcmd:lcs=tab\:|- list # include Make.color LIBS = ../libs BOARD = arduino:avr:mega PORT = /dev/ttyArduinoMega # PORT = /dev/ttyACM0 SPEED = 115200 CONFIG = ./.config.yaml VERBOSE = -v .PHONY: all upload monitor list clean help more_help all: ## Compile arduino-cli --config-file $(CONFIG) --library $(LIBS) compile $(VERBOSE) --fqbn $(BOARD) *.ino |sed "s/\[90m/[96m/g" # paths FgHiBlack -> FgHiCyan upload: ## Upload arduino-cli --config-file $(CONFIG) upload $(VERBOSE) -p $(PORT) --fqbn $(BOARD) . monitor: ## Serial connection screen $(PORT) $(SPEED); killall screen; killall screen; true # make chce uspech list: ## List of boards attached arduino-cli --config-file $(CONFIG) board list clean: ## does nothing now @echo "nothing to do" help: ## Show help about main commands {{{ @egrep -h '(^|[^#])##\s' $(MAKEFILE_LIST) | \ sed "s/^# /# /;s/{{{//;s/}}}//" | \ awk 'BEGIN {FS = ":.*?#[#] "}; {printf "$(shell echo -en $(COLORS))$(BRIGHTGREEN);$(BG_BLUE);$(BOLD)m%-15s$(shell echo -en $(COLORS))$(RESET)m %s\n", $$1, $$2}' @# awk %-15s fits string left, padding with spaces - works better than tabs # }}} more_help: ## Show help about all docummented targets {{{ @egrep -h '###?\s' $(MAKEFILE_LIST) | \ sed "s/^# /# /;s/{{{//;s/}}}//" | \ awk 'BEGIN {FS = ":.*?#[#] "}; {printf "$(shell echo -en $(COLORS))$(BRIGHTGREEN);$(BG_BLUE);$(BOLD)m%-15s$(shell echo -en $(COLORS))$(RESET)m %s\n", $$1, $$2}' # }}}