Skip to content

Commit bed2376

Browse files
committed
Added message on how to exit monitor
1 parent 74fe93f commit bed2376

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "raftcli"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
authors = ["Rob Dobson <[email protected]>"]
55
license = "MIT"
66
keywords = ["cli", "esp32", "espressif", "raft", "framework"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Options:
6969
-h, --help Print help
7070
```
7171

72+
To exit the app press ESC
73+
7274
## Installation
7375

7476
You can either install this app from the crates.io package registry (which is part of the Rust ecosystem) or build from source code.

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
[] possibly include size of flash as a user input - issues with this are different flash types such as OCTAL in addition to size
77
[] fix problem invalid string ... thread 'tokio-runtime-worker' panicked at src/serial_monitor.rs:179:68: Failed to read from RX stream: Custom { kind: Other, error: "Invalid String" }
88
[] add monitor as option in Makefile?
9+
[] bug noticed on Mac with invalid chars immediately after boot

raft_templates/Makefile

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
# Build Project
22
DOCKER ?= 1
3-
WSL ?= $(if $(findstring Windows_NT,$(OS)),1,0)
3+
4+
# Detect whether the OS is Windows Subsystem for Linux (WSL)
5+
ifeq ($(OS),Windows_NT)
6+
WSL ?= 0
7+
else
8+
WSL ?= $(shell uname -r | grep -i microsoft > /dev/null && echo 1 || echo 0)
9+
endif
10+
11+
# Set the ESP IDF version
412
ESP_IDF_PATH ?= ~/esp/esp-idf-v{{esp_idf_version}}
13+
14+
# Set the build base folders
515
BUILD_BASE_FOLDER ?= build
616
BUILD_CONFIG_BASE_DIR = systypes
17+
BUILD_RAFT_ARTEFACTS_DIR ?= build_raft_artefacts
18+
19+
# Set the SysType
720
SYSTYPE ?= $(notdir $(firstword $(filter-out $(BUILD_CONFIG_BASE_DIR)/Common, $(wildcard $(BUILD_CONFIG_BASE_DIR)/*))))
21+
22+
# Set the build configuration folders based on the SysType
823
BUILD_CONFIG_DIR = $(BUILD_CONFIG_BASE_DIR)/$(SYSTYPE)
924
COMMON_CONFIG_DIR = $(BUILD_CONFIG_BASE_DIR)/Common
10-
BUILD_RAFT_ARTEFACTS_DIR ?= build_raft_artefacts
25+
26+
# Set the build directory
1127
BUILD_DIR = $(BUILD_BASE_FOLDER)/$(SYSTYPE)
1228
ROOTDIR = $(realpath $(CURDIR))
29+
30+
# Set the sdkconfig files
1331
SDKCONFIG_DEFAULTS_FILE ?= $(BUILD_CONFIG_DIR)/sdkconfig.defaults
1432
SDKCONFIG_FILE ?= $(BUILD_RAFT_ARTEFACTS_DIR)/sdkconfig
33+
34+
# Set the target binary
1535
TARGET_BINARY = $(BUILD_DIR)/$(SYSTYPE).bin
16-
# DOCKER_EXEC ?= docker run --rm -v $(ROOTDIR):/project -w /project espressif/idf:v5.1.2
36+
37+
# Set the build commands
1738
DOCKER_EXEC = docker build -t raftbuilder . && docker run --rm -v $(ROOTDIR):/project -w /project raftbuilder
1839
LOCAL_EXEC = . $(ESP_IDF_PATH)/export.sh
1940
CMD ?= idf.py -B $(BUILD_DIR) build
2041

42+
# Prepare build commands depending on the OS
2143
ifeq ($(WSL),1)
2244
SERIAL_MONITOR ?= raft.exe monitor
2345
PYTHON_FOR_FLASH ?= python.exe
@@ -45,18 +67,22 @@ BUILD_TARGET=\
4567
$(LOCAL_EXEC) && $(CMD)
4668
endif
4769

70+
# Default target
4871
all: build
4972

5073
# Dependencies of target binary
5174
$(TARGET_BINARY): $(wildcard $(BUILD_CONFIG_DIR)/*) $(wildcard $(COMMON_CONFIG_DIR)/*) $(wildcard $(COMMON_CONFIG_DIR)/FSImage/*) $(wildcard $(COMMON_CONFIG_DIR)/WebUI*)
5275
@$(DELETE_BUILD_FOLDERS)
5376

77+
# Clean the build
5478
clean:
5579
@$(DELETE_BUILD_FOLDERS)
5680

81+
# Build the project
5782
build: $(TARGET_BINARY)
5883
@$(BUILD_TARGET)
5984

85+
# Flash the project
6086
ifneq ($(SERIAL_MONITOR),)
6187
flash: build
6288
@$(PYTHON_FOR_FLASH) $(BUILD_DIR)/_deps/raftcore-src/scripts/flashUsingPartitionCSV.py $(BUILD_RAFT_ARTEFACTS_DIR)/partitions.csv $(BUILD_DIR) $(SYSTYPE).bin $(PORT) -s $(SDKCONFIG_FILE) -f fs.bin
@@ -66,4 +92,5 @@ flash: build
6692
@$(PYTHON_FOR_FLASH) $(BUILD_DIR)/_deps/raftcore-src/scripts/flashUsingPartitionCSV.py $(BUILD_RAFT_ARTEFACTS_DIR)/partitions.csv $(BUILD_DIR) $(SYSTYPE).bin $(PORT) -s $(SDKCONFIG_FILE) -f fs.bin
6793
endif
6894

69-
.PHONY: build clean flash test
95+
# Phony targets to avoid name clashes with files
96+
.PHONY: build clean flash test

src/serial_monitor.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ pub async fn start(port: String, baud: u32, log: bool, log_folder: String) -> to
173173
// Clone the log file for use in the serial_rx task
174174
let log_file_clone = log_file.clone();
175175

176+
// Write welcome message to the termainal
177+
println!("Raft Serial Monitor - press Esc (or Ctrl+X) to exit");
178+
176179
// Create a separate task to read from the serial port and send to the terminal
177180
tokio::spawn(async move {
178181
loop {
@@ -241,11 +244,15 @@ pub async fn start(port: String, baud: u32, log: bool, log_folder: String) -> to
241244

242245
// Handle key press
243246
match key.code {
244-
// Break out of the serial monitor on Esc key
247+
// Break out of the serial monitor on Esc key or Ctrl+X
245248
KeyCode::Esc => {
246249
let _ = oneshot_exit_send.send(());
247250
break;
248251
},
252+
KeyCode::Char('x') if key.modifiers == crossterm::event::KeyModifiers::CONTROL => {
253+
let _ = oneshot_exit_send.send(());
254+
break;
255+
},
249256
// Check for Enter key and send the user input buffer
250257
KeyCode::Enter => {
251258
// Clear the user input display line before sending.

0 commit comments

Comments
 (0)