diff --git a/.gitignore b/.gitignore index 52f03525..d7ab86ca 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ .dep/ /build* CMakeFiles/ +cmake-build-debug/ # Debugging .gdbinit* diff --git a/firmware/application/usb_serial_asyncmsg.hpp b/firmware/application/usb_serial_asyncmsg.hpp index 58869407..17b22f84 100644 --- a/firmware/application/usb_serial_asyncmsg.hpp +++ b/firmware/application/usb_serial_asyncmsg.hpp @@ -37,6 +37,8 @@ class UsbSerialAsyncmsg { template static void asyncmsg(const std::vector& data); + + static void asyncmsg(const char* data); // string literal }; /*Notes: @@ -45,15 +47,16 @@ class UsbSerialAsyncmsg { * - so delete all debug things before you push your code to production * - use this client to filter only PP devices: https://github.com/zxkmm/Pyserial-Demo-portapack * - usage: - * #include "usb_serial_debug_bridge.hpp" + * portapack::async_tx_enabled = true; // note that use this when debugging, unless the msg would be forbidden. but don't use this in production, since it's not real async and multiple serial transmittions will broken each other. if this class is used in other scene in the future, just use command to cover (protect your serial tramsnitton) in your extern thing: asyncmsg enable --- your cmd --- asyncmsg disable + * #include "usb_serial_asyncmsg.cpp" * UsbSerialAsyncmsg::asyncmsg("Hello PP"); * */ /// value // to_string_bin/ to_string_decimal/ to_string_hex/ to_string_hex_array/ to_string_dec_uint/ to_string_dec_int etc seems usellss so i didn't add them here +// usage: UsbSerialAsyncmsg::asyncmsg(num); template <> -// usage: UsbSerialAsyncmsg::asyncmsg(num); void UsbSerialAsyncmsg::asyncmsg(const int64_t& data) { if (!portapack::async_tx_enabled) { return; @@ -130,6 +133,8 @@ void UsbSerialAsyncmsg::asyncmsg(const std::filesystem::p } /// string + +// string obj template <> // usage: UsbSerialAsyncmsg::asyncmsg(str); void UsbSerialAsyncmsg::asyncmsg(const std::string& data) { @@ -139,6 +144,15 @@ void UsbSerialAsyncmsg::asyncmsg(const std::string& data) { chprintf((BaseSequentialStream*)&SUSBD1, "%s\r\n", data.c_str()); } +// string literal AKA char[] +// usage: UsbSerialAsyncmsg::asyncmsg("abc"); +void UsbSerialAsyncmsg::asyncmsg(const char* data) { + if (!portapack::async_tx_enabled) { + return; + } + chprintf((BaseSequentialStream*)&SUSBD1, "%s\r\n", data); +} + /// vec worker // ussgae: UsbSerialAsyncmsg::asyncmsg(vec); template