Progress bar, CMake fixes
This commit is contained in:
@@ -6,12 +6,11 @@ project(TEST)
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(TEST_SRCS main.cpp TimeoutSerial.cpp Ymodem.cpp YmodemFileReceive.cpp)
|
set(TEST_SRCS main.cpp TimeoutSerial.cpp Ymodem.cpp YmodemFileReceive.cpp)
|
||||||
add_definitions(-DBOOST_LOG_DYN_LINK)
|
add_definitions(-DBOOST_LOG_DYN_LINK)
|
||||||
add_executable(timeout ${TEST_SRCS})
|
add_executable(usbserial-dw ${TEST_SRCS})
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
|
||||||
|
|
||||||
## Link libraries
|
## Link libraries
|
||||||
set(BOOST_LIBS date_time system log program_options)
|
set(BOOST_LIBS date_time system log program_options)
|
||||||
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
|
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
|
||||||
target_link_libraries(timeout ${Boost_LIBRARIES})
|
target_link_libraries(usbserial-dw ${Boost_LIBRARIES})
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(timeout ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(usbserial-dw ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
|||||||
208
Makefile
208
Makefile
@@ -1,208 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.16
|
|
||||||
|
|
||||||
# Default target executed when no arguments are given to make.
|
|
||||||
default_target: all
|
|
||||||
|
|
||||||
.PHONY : default_target
|
|
||||||
|
|
||||||
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
|
||||||
.NOTPARALLEL:
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Special targets provided by cmake.
|
|
||||||
|
|
||||||
# Disable implicit rules so canonical targets will work.
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
|
|
||||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
|
||||||
SUFFIXES =
|
|
||||||
|
|
||||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
|
||||||
|
|
||||||
|
|
||||||
# Suppress display of executed commands.
|
|
||||||
$(VERBOSE).SILENT:
|
|
||||||
|
|
||||||
|
|
||||||
# A target that is always out of date.
|
|
||||||
cmake_force:
|
|
||||||
|
|
||||||
.PHONY : cmake_force
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Set environment variables for the build.
|
|
||||||
|
|
||||||
# The shell in which to execute make rules.
|
|
||||||
SHELL = /bin/sh
|
|
||||||
|
|
||||||
# The CMake executable.
|
|
||||||
CMAKE_COMMAND = /usr/bin/cmake
|
|
||||||
|
|
||||||
# The command to remove a file.
|
|
||||||
RM = /usr/bin/cmake -E remove -f
|
|
||||||
|
|
||||||
# Escaping for special characters.
|
|
||||||
EQUALS = =
|
|
||||||
|
|
||||||
# The top-level source directory on which CMake was run.
|
|
||||||
CMAKE_SOURCE_DIR = /home/jaro/serialport-downloader
|
|
||||||
|
|
||||||
# The top-level build directory on which CMake was run.
|
|
||||||
CMAKE_BINARY_DIR = /home/jaro/serialport-downloader
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Targets provided globally by CMake.
|
|
||||||
|
|
||||||
# Special rule for the target rebuild_cache
|
|
||||||
rebuild_cache:
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
|
||||||
/usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
|
||||||
.PHONY : rebuild_cache
|
|
||||||
|
|
||||||
# Special rule for the target rebuild_cache
|
|
||||||
rebuild_cache/fast: rebuild_cache
|
|
||||||
|
|
||||||
.PHONY : rebuild_cache/fast
|
|
||||||
|
|
||||||
# Special rule for the target edit_cache
|
|
||||||
edit_cache:
|
|
||||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
|
|
||||||
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
|
|
||||||
.PHONY : edit_cache
|
|
||||||
|
|
||||||
# Special rule for the target edit_cache
|
|
||||||
edit_cache/fast: edit_cache
|
|
||||||
|
|
||||||
.PHONY : edit_cache/fast
|
|
||||||
|
|
||||||
# The main all target
|
|
||||||
all: cmake_check_build_system
|
|
||||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/serialport-downloader/CMakeFiles /home/jaro/serialport-downloader/CMakeFiles/progress.marks
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 all
|
|
||||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/jaro/serialport-downloader/CMakeFiles 0
|
|
||||||
.PHONY : all
|
|
||||||
|
|
||||||
# The main clean target
|
|
||||||
clean:
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 clean
|
|
||||||
.PHONY : clean
|
|
||||||
|
|
||||||
# The main clean target
|
|
||||||
clean/fast: clean
|
|
||||||
|
|
||||||
.PHONY : clean/fast
|
|
||||||
|
|
||||||
# Prepare targets for installation.
|
|
||||||
preinstall: all
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 preinstall
|
|
||||||
.PHONY : preinstall
|
|
||||||
|
|
||||||
# Prepare targets for installation.
|
|
||||||
preinstall/fast:
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 preinstall
|
|
||||||
.PHONY : preinstall/fast
|
|
||||||
|
|
||||||
# clear depends
|
|
||||||
depend:
|
|
||||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
|
||||||
.PHONY : depend
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Target rules for targets named timeout
|
|
||||||
|
|
||||||
# Build rule for target.
|
|
||||||
timeout: cmake_check_build_system
|
|
||||||
$(MAKE) -f CMakeFiles/Makefile2 timeout
|
|
||||||
.PHONY : timeout
|
|
||||||
|
|
||||||
# fast build rule for target.
|
|
||||||
timeout/fast:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/build
|
|
||||||
.PHONY : timeout/fast
|
|
||||||
|
|
||||||
TimeoutSerial.o: TimeoutSerial.cpp.o
|
|
||||||
|
|
||||||
.PHONY : TimeoutSerial.o
|
|
||||||
|
|
||||||
# target to build an object file
|
|
||||||
TimeoutSerial.cpp.o:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/TimeoutSerial.cpp.o
|
|
||||||
.PHONY : TimeoutSerial.cpp.o
|
|
||||||
|
|
||||||
TimeoutSerial.i: TimeoutSerial.cpp.i
|
|
||||||
|
|
||||||
.PHONY : TimeoutSerial.i
|
|
||||||
|
|
||||||
# target to preprocess a source file
|
|
||||||
TimeoutSerial.cpp.i:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/TimeoutSerial.cpp.i
|
|
||||||
.PHONY : TimeoutSerial.cpp.i
|
|
||||||
|
|
||||||
TimeoutSerial.s: TimeoutSerial.cpp.s
|
|
||||||
|
|
||||||
.PHONY : TimeoutSerial.s
|
|
||||||
|
|
||||||
# target to generate assembly for a file
|
|
||||||
TimeoutSerial.cpp.s:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/TimeoutSerial.cpp.s
|
|
||||||
.PHONY : TimeoutSerial.cpp.s
|
|
||||||
|
|
||||||
main.o: main.cpp.o
|
|
||||||
|
|
||||||
.PHONY : main.o
|
|
||||||
|
|
||||||
# target to build an object file
|
|
||||||
main.cpp.o:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/main.cpp.o
|
|
||||||
.PHONY : main.cpp.o
|
|
||||||
|
|
||||||
main.i: main.cpp.i
|
|
||||||
|
|
||||||
.PHONY : main.i
|
|
||||||
|
|
||||||
# target to preprocess a source file
|
|
||||||
main.cpp.i:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/main.cpp.i
|
|
||||||
.PHONY : main.cpp.i
|
|
||||||
|
|
||||||
main.s: main.cpp.s
|
|
||||||
|
|
||||||
.PHONY : main.s
|
|
||||||
|
|
||||||
# target to generate assembly for a file
|
|
||||||
main.cpp.s:
|
|
||||||
$(MAKE) -f CMakeFiles/timeout.dir/build.make CMakeFiles/timeout.dir/main.cpp.s
|
|
||||||
.PHONY : main.cpp.s
|
|
||||||
|
|
||||||
# Help Target
|
|
||||||
help:
|
|
||||||
@echo "The following are some of the valid targets for this Makefile:"
|
|
||||||
@echo "... all (the default if no target is provided)"
|
|
||||||
@echo "... clean"
|
|
||||||
@echo "... depend"
|
|
||||||
@echo "... rebuild_cache"
|
|
||||||
@echo "... edit_cache"
|
|
||||||
@echo "... timeout"
|
|
||||||
@echo "... TimeoutSerial.o"
|
|
||||||
@echo "... TimeoutSerial.i"
|
|
||||||
@echo "... TimeoutSerial.s"
|
|
||||||
@echo "... main.o"
|
|
||||||
@echo "... main.i"
|
|
||||||
@echo "... main.s"
|
|
||||||
.PHONY : help
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Special targets to cleanup operation of make.
|
|
||||||
|
|
||||||
# Special rule to run CMake to check the build system integrity.
|
|
||||||
# No rule that depends on this can have commands that come from listfiles
|
|
||||||
# because they might be regenerated.
|
|
||||||
cmake_check_build_system:
|
|
||||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
|
||||||
.PHONY : cmake_check_build_system
|
|
||||||
|
|
||||||
8
main.cpp
8
main.cpp
@@ -110,6 +110,12 @@ static void init_log(void)
|
|||||||
fsSink->locked_backend()->auto_flush(true);
|
fsSink->locked_backend()->auto_flush(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showProgress(int num)
|
||||||
|
{
|
||||||
|
cout << "Downloading: (" << num << "/100) %" ;
|
||||||
|
cout.put('\r');
|
||||||
|
cout << flush;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@@ -235,6 +241,8 @@ int main(int argc, char* argv[])
|
|||||||
modem.setSerialPort(&serial);
|
modem.setSerialPort(&serial);
|
||||||
modem.setFilePath(path);
|
modem.setFilePath(path);
|
||||||
modem.setDefaultFileName(filename);
|
modem.setDefaultFileName(filename);
|
||||||
|
modem.receiveProgress.connect(showProgress);
|
||||||
|
|
||||||
modem.startReceive();
|
modem.startReceive();
|
||||||
|
|
||||||
boost::this_thread::sleep(posix_time::seconds(1));
|
boost::this_thread::sleep(posix_time::seconds(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user