mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
add literal str print in asyncmsg (#2113)
* add literal str print in asyncmsg * remove debug things * accept suggestion per gull * fix documentary
This commit is contained in:
parent
b2da21b88a
commit
03ca87b13e
1
.gitignore
vendored
1
.gitignore
vendored
@ -51,6 +51,7 @@
|
|||||||
.dep/
|
.dep/
|
||||||
/build*
|
/build*
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
|
cmake-build-debug/
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
.gdbinit*
|
.gdbinit*
|
||||||
|
@ -37,6 +37,8 @@ class UsbSerialAsyncmsg {
|
|||||||
|
|
||||||
template <typename VECTORCOVER>
|
template <typename VECTORCOVER>
|
||||||
static void asyncmsg(const std::vector<VECTORCOVER>& data);
|
static void asyncmsg(const std::vector<VECTORCOVER>& data);
|
||||||
|
|
||||||
|
static void asyncmsg(const char* data); // string literal
|
||||||
};
|
};
|
||||||
|
|
||||||
/*Notes:
|
/*Notes:
|
||||||
@ -45,15 +47,16 @@ class UsbSerialAsyncmsg {
|
|||||||
* - so delete all debug things before you push your code to production
|
* - 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
|
* - use this client to filter only PP devices: https://github.com/zxkmm/Pyserial-Demo-portapack
|
||||||
* - usage:
|
* - 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");
|
* UsbSerialAsyncmsg::asyncmsg("Hello PP");
|
||||||
* */
|
* */
|
||||||
|
|
||||||
/// value
|
/// 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
|
// 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 <>
|
template <>
|
||||||
// usage: UsbSerialAsyncmsg::asyncmsg(num);
|
|
||||||
void UsbSerialAsyncmsg::asyncmsg<int64_t>(const int64_t& data) {
|
void UsbSerialAsyncmsg::asyncmsg<int64_t>(const int64_t& data) {
|
||||||
if (!portapack::async_tx_enabled) {
|
if (!portapack::async_tx_enabled) {
|
||||||
return;
|
return;
|
||||||
@ -130,6 +133,8 @@ void UsbSerialAsyncmsg::asyncmsg<std::filesystem::path>(const std::filesystem::p
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// string
|
/// string
|
||||||
|
|
||||||
|
// string obj
|
||||||
template <>
|
template <>
|
||||||
// usage: UsbSerialAsyncmsg::asyncmsg(str);
|
// usage: UsbSerialAsyncmsg::asyncmsg(str);
|
||||||
void UsbSerialAsyncmsg::asyncmsg<std::string>(const std::string& data) {
|
void UsbSerialAsyncmsg::asyncmsg<std::string>(const std::string& data) {
|
||||||
@ -139,6 +144,15 @@ void UsbSerialAsyncmsg::asyncmsg<std::string>(const std::string& data) {
|
|||||||
chprintf((BaseSequentialStream*)&SUSBD1, "%s\r\n", data.c_str());
|
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
|
/// vec worker
|
||||||
// ussgae: UsbSerialAsyncmsg::asyncmsg(vec);
|
// ussgae: UsbSerialAsyncmsg::asyncmsg(vec);
|
||||||
template <typename VECTORCOVER>
|
template <typename VECTORCOVER>
|
||||||
|
Loading…
Reference in New Issue
Block a user