diff --git a/components/basic/port/linux/maix_sys_linux.cpp b/components/basic/port/linux/maix_sys_linux.cpp index 8aeceb29..09156443 100644 --- a/components/basic/port/linux/maix_sys_linux.cpp +++ b/components/basic/port/linux/maix_sys_linux.cpp @@ -6,17 +6,18 @@ namespace maix::sys { static void signal_handle(int signal) { - const char *signal_msg = NULL; switch (signal) { case SIGINT: maix::app::set_exit_flag(true); +#if CONFIG_BUILD_WITH_MAIXPY raise(SIGINT); +#endif break; - default: signal_msg = "UNKNOWN"; break; + default: break; } } void register_default_signal_handle() { - signal(SIGILL, signal_handle); + signal(SIGINT, signal_handle); } } diff --git a/components/basic/port/maixcam/maix_sys_maixcam.cpp b/components/basic/port/maixcam/maix_sys_maixcam.cpp index 0a09a52d..c1c4338b 100644 --- a/components/basic/port/maixcam/maix_sys_maixcam.cpp +++ b/components/basic/port/maixcam/maix_sys_maixcam.cpp @@ -6,17 +6,18 @@ namespace maix::sys { static void signal_handle(int signal) { - const char *signal_msg = NULL; switch (signal) { case SIGINT: maix::app::set_exit_flag(true); +#if CONFIG_BUILD_WITH_MAIXPY raise(SIGINT); +#endif break; - default: signal_msg = "UNKNOWN"; break; + default: break; } } void register_default_signal_handle() { - signal(SIGILL, signal_handle); + signal(SIGINT, signal_handle); } } \ No newline at end of file diff --git a/components/vision/port/linux/maix_rtmp_linux.cpp b/components/vision/port/linux/maix_rtmp_linux.cpp index ee0835ed..6eb65e8e 100644 --- a/components/vision/port/linux/maix_rtmp_linux.cpp +++ b/components/vision/port/linux/maix_rtmp_linux.cpp @@ -1,11 +1,12 @@ #include "maix_rtmp.hpp" namespace maix::rtmp { - Rtmp::Rtmp(std::string host, int port, std::string app, std::string stream) { + Rtmp::Rtmp(std::string host, int port, std::string app, std::string stream, int bitrate) { _host = host; _port = port; _app = app; _stream = stream; + _bitrate = bitrate; } Rtmp::~Rtmp() { diff --git a/examples/audio_demo/main/src/main.cpp b/examples/audio_demo/main/src/main.cpp index 4c9a089b..7ef04a7e 100644 --- a/examples/audio_demo/main/src/main.cpp +++ b/examples/audio_demo/main/src/main.cpp @@ -185,8 +185,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/camera_display/main/src/main.cpp b/examples/camera_display/main/src/main.cpp index e028e49f..6ca54702 100644 --- a/examples/camera_display/main/src/main.cpp +++ b/examples/camera_display/main/src/main.cpp @@ -193,8 +193,8 @@ static int cmd_loop(camera::Camera *cam) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/comm_protocol/main/src/main.cpp b/examples/comm_protocol/main/src/main.cpp index 3ecbd0de..5e17c56d 100644 --- a/examples/comm_protocol/main/src/main.cpp +++ b/examples/comm_protocol/main/src/main.cpp @@ -45,8 +45,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/comm_uart/main/src/main.cpp b/examples/comm_uart/main/src/main.cpp index d882f46b..6d356919 100644 --- a/examples/comm_uart/main/src/main.cpp +++ b/examples/comm_uart/main/src/main.cpp @@ -47,8 +47,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/gui_lvgl/main/src/main.cpp b/examples/gui_lvgl/main/src/main.cpp index d05c9f3e..15acecdf 100644 --- a/examples/gui_lvgl/main/src/main.cpp +++ b/examples/gui_lvgl/main/src/main.cpp @@ -58,8 +58,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/gui_simple/main/src/main.cpp b/examples/gui_simple/main/src/main.cpp index 3c30553b..dd342d4b 100644 --- a/examples/gui_simple/main/src/main.cpp +++ b/examples/gui_simple/main/src/main.cpp @@ -71,8 +71,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/hello_world/main/src/main.cpp b/examples/hello_world/main/src/main.cpp index 87e8a6fc..cdde1a2a 100644 --- a/examples/hello_world/main/src/main.cpp +++ b/examples/hello_world/main/src/main.cpp @@ -38,8 +38,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/i18n/main/src/main.cpp b/examples/i18n/main/src/main.cpp index 933c3894..ddb4fbc9 100644 --- a/examples/i18n/main/src/main.cpp +++ b/examples/i18n/main/src/main.cpp @@ -41,8 +41,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/image_method/main/src/main.cpp b/examples/image_method/main/src/main.cpp index 0e4f8260..f05453fc 100644 --- a/examples/image_method/main/src/main.cpp +++ b/examples/image_method/main/src/main.cpp @@ -5368,8 +5368,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/image_show/main/src/main.cpp b/examples/image_show/main/src/main.cpp index e76326bb..b04f783a 100644 --- a/examples/image_show/main/src/main.cpp +++ b/examples/image_show/main/src/main.cpp @@ -55,8 +55,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/jpg_stream_demo/main/src/main.cpp b/examples/jpg_stream_demo/main/src/main.cpp index 9b8205e9..65339f4a 100644 --- a/examples/jpg_stream_demo/main/src/main.cpp +++ b/examples/jpg_stream_demo/main/src/main.cpp @@ -53,8 +53,8 @@ std::string html = int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/key_demo/main/src/main.cpp b/examples/key_demo/main/src/main.cpp index 8fe08a04..6cb8edf1 100644 --- a/examples/key_demo/main/src/main.cpp +++ b/examples/key_demo/main/src/main.cpp @@ -51,8 +51,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/nn_classifier/main/src/main.cpp b/examples/nn_classifier/main/src/main.cpp index 0177640f..f3bd53bb 100644 --- a/examples/nn_classifier/main/src/main.cpp +++ b/examples/nn_classifier/main/src/main.cpp @@ -75,8 +75,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/nn_runner/main/src/main.cpp b/examples/nn_runner/main/src/main.cpp index 18d0e145..74bccaff 100644 --- a/examples/nn_runner/main/src/main.cpp +++ b/examples/nn_runner/main/src/main.cpp @@ -249,8 +249,8 @@ end: int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/opencv_demo/main/src/main.cpp b/examples/opencv_demo/main/src/main.cpp index bbd0e4ed..f47594f4 100644 --- a/examples/opencv_demo/main/src/main.cpp +++ b/examples/opencv_demo/main/src/main.cpp @@ -207,8 +207,8 @@ int _main(int argc, char *argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/peripheral_gpio/main/src/main.cpp b/examples/peripheral_gpio/main/src/main.cpp index 87e8a6fc..cdde1a2a 100644 --- a/examples/peripheral_gpio/main/src/main.cpp +++ b/examples/peripheral_gpio/main/src/main.cpp @@ -38,8 +38,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/peripheral_i2c_eeprom/main/src/main.cpp b/examples/peripheral_i2c_eeprom/main/src/main.cpp index 8610f571..f296ba13 100644 --- a/examples/peripheral_i2c_eeprom/main/src/main.cpp +++ b/examples/peripheral_i2c_eeprom/main/src/main.cpp @@ -82,8 +82,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/peripheral_pwm_servo/main/src/main.cpp b/examples/peripheral_pwm_servo/main/src/main.cpp index e6fa4581..a3aa60be 100644 --- a/examples/peripheral_pwm_servo/main/src/main.cpp +++ b/examples/peripheral_pwm_servo/main/src/main.cpp @@ -49,8 +49,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/rtmp_demo/main/src/main.cpp b/examples/rtmp_demo/main/src/main.cpp index 1bb852f5..6bba9b12 100644 --- a/examples/rtmp_demo/main/src/main.cpp +++ b/examples/rtmp_demo/main/src/main.cpp @@ -111,8 +111,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/rtsp_demo/main/src/main.cpp b/examples/rtsp_demo/main/src/main.cpp index 16e5f318..87d84757 100644 --- a/examples/rtsp_demo/main/src/main.cpp +++ b/examples/rtsp_demo/main/src/main.cpp @@ -62,8 +62,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/video_demo/main/src/main.cpp b/examples/video_demo/main/src/main.cpp index 871bda60..6195ee06 100644 --- a/examples/video_demo/main/src/main.cpp +++ b/examples/video_demo/main/src/main.cpp @@ -303,8 +303,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/video_record_mp4/main/src/main.cpp b/examples/video_record_mp4/main/src/main.cpp index 4964d702..dbdc7a7b 100644 --- a/examples/video_record_mp4/main/src/main.cpp +++ b/examples/video_record_mp4/main/src/main.cpp @@ -37,8 +37,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/websocket_client/main/src/main.cpp b/examples/websocket_client/main/src/main.cpp index 3071d3cb..dfa6eb6f 100644 --- a/examples/websocket_client/main/src/main.cpp +++ b/examples/websocket_client/main/src/main.cpp @@ -109,8 +109,8 @@ int _main(int argc, char* argv[]) { int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/websocket_server/main/src/main.cpp b/examples/websocket_server/main/src/main.cpp index e07ed1f6..ac22afff 100644 --- a/examples/websocket_server/main/src/main.cpp +++ b/examples/websocket_server/main/src/main.cpp @@ -68,8 +68,8 @@ int _main(int argc, char* argv[]) { int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/examples/wifi_demo/main/src/main.cpp b/examples/wifi_demo/main/src/main.cpp index 932749e5..8c7f040e 100644 --- a/examples/wifi_demo/main/src/main.cpp +++ b/examples/wifi_demo/main/src/main.cpp @@ -44,8 +44,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/test/cvi_tpu_demo/main/src/main.cpp b/test/cvi_tpu_demo/main/src/main.cpp index f399d343..4f6f1636 100644 --- a/test/cvi_tpu_demo/main/src/main.cpp +++ b/test/cvi_tpu_demo/main/src/main.cpp @@ -134,8 +134,8 @@ int _main(int argc, char **argv) { int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/test/cvi_tpu_matmul/main/src/main.cpp b/test/cvi_tpu_matmul/main/src/main.cpp index dabce60e..d7e56a21 100644 --- a/test/cvi_tpu_matmul/main/src/main.cpp +++ b/test/cvi_tpu_matmul/main/src/main.cpp @@ -124,8 +124,8 @@ int _main(int argc, char **argv) { int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed. diff --git a/tools/project_template/main/src/main.cpp b/tools/project_template/main/src/main.cpp index 46da8011..6b733d4c 100644 --- a/tools/project_template/main/src/main.cpp +++ b/tools/project_template/main/src/main.cpp @@ -26,8 +26,8 @@ int _main(int argc, char* argv[]) int main(int argc, char* argv[]) { - // Catch SIGINT signal(e.g. Ctrl + C), and set exit flag to true. - signal(SIGINT, [](int sig){ app::set_exit_flag(true); }); + // Catch signal and process + sys::register_default_signal_handle(); // Use CATCH_EXCEPTION_RUN_RETURN to catch exception, // if we don't catch exception, when program throw exception, the objects will not be destructed.