@@ -66,7 +66,7 @@ static bool s_echoEnabled = true;
6666static std::vector<OpenShock::Serial::CommandGroup> s_commandGroups;
6767static std::unordered_map<std::string_view, OpenShock::Serial::CommandGroup, std::hash_ci, std::equals_ci> s_commandHandlers;
6868
69- void _printCompleteHelp ()
69+ static void print_help_complete ()
7070{
7171 std::size_t commandCount = 0 ;
7272 std::size_t longestCommand = 0 ;
@@ -126,7 +126,7 @@ void _printCompleteHelp()
126126 ::Serial.print (buffer.data ());
127127}
128128
129- void _printCommandHelp (Serial::CommandGroup& group)
129+ static void print_help_command (Serial::CommandGroup& group)
130130{
131131 std::size_t size = 0 ;
132132 for (const auto & command : group.commands ()) {
@@ -263,21 +263,21 @@ void _handleHelpCommand(std::string_view arg, bool isAutomated)
263263{
264264 arg = OpenShock::StringTrim (arg);
265265 if (arg.empty ()) {
266- _printCompleteHelp ();
266+ print_help_complete ();
267267 return ;
268268 }
269269
270270 // Get help for a specific command
271271 auto it = s_commandHandlers.find (arg);
272272 if (it != s_commandHandlers.end ()) {
273- _printCommandHelp (it->second );
273+ print_help_command (it->second );
274274 return ;
275275 }
276276
277277 SERPR_ERROR (" Command \" %.*s\" not found" , arg.length (), arg.data ());
278278}
279279
280- void RegisterCommandHandler (const OpenShock::Serial::CommandGroup& handler)
280+ static void register_command_handler (const OpenShock::Serial::CommandGroup& handler)
281281{
282282 s_commandHandlers[handler.name ()] = handler;
283283}
@@ -366,7 +366,7 @@ enum class SerialReadResult {
366366 AutoCompleteRequest,
367367};
368368
369- SerialReadResult _tryReadSerialLine (SerialBuffer& buffer)
369+ static SerialReadResult try_read_serial_line (SerialBuffer& buffer)
370370{
371371 // Check if there's any data available
372372 int available = ::Serial.available ();
@@ -413,7 +413,7 @@ SerialReadResult _tryReadSerialLine(SerialBuffer& buffer)
413413 return SerialReadResult::Data;
414414}
415415
416- void _skipSerialWhitespaces (SerialBuffer& buffer)
416+ static void skip_serial_whitespaces (SerialBuffer& buffer)
417417{
418418 int available = ::Serial.available ();
419419
@@ -427,12 +427,12 @@ void _skipSerialWhitespaces(SerialBuffer& buffer)
427427 }
428428}
429429
430- void _echoBuffer (std::string_view buffer)
430+ static void echo_buffer (std::string_view buffer)
431431{
432432 ::Serial.printf (CLEAR_LINE " > %.*s" , buffer.size (), buffer.data ());
433433}
434434
435- void _echoHandleSerialInput (std::string_view buffer, bool hasData)
435+ static void echo_handle_serial_input (std::string_view buffer, bool hasData)
436436{
437437 static int64_t lastActivity = 0 ;
438438 static bool hasChanges = false ;
@@ -455,13 +455,13 @@ void _echoHandleSerialInput(std::string_view buffer, bool hasData)
455455
456456 // If theres has been received data, but no new data for a while, echo the buffer
457457 if (hasChanges && OpenShock::millis () - lastActivity > PASTE_INTERVAL_THRESHOLD_MS) {
458- _echoBuffer (buffer);
458+ echo_buffer (buffer);
459459 hasChanges = false ;
460460 lastActivity = OpenShock::millis ();
461461 }
462462}
463463
464- void _processSerialLine (std::string_view line)
464+ static void process_serial_line (std::string_view line)
465465{
466466 line = OpenShock::StringTrim (line);
467467 if (line.empty ()) {
@@ -475,7 +475,7 @@ void _processSerialLine(std::string_view line)
475475 if (isAutomated) {
476476 line = line.substr (1 );
477477 } else if (s_echoEnabled) {
478- _echoBuffer (line);
478+ echo_buffer (line);
479479 ::Serial.println ();
480480 }
481481
@@ -513,7 +513,7 @@ void _processSerialLine(std::string_view line)
513513
514514 // Check if the subcommand requires arguments
515515 if (cmd.arguments ().size () > 1 && parts.size () < 2 ) {
516- _printCommandHelp (it->second );
516+ print_help_command (it->second );
517517 return ;
518518 }
519519
@@ -535,7 +535,7 @@ void _processSerialLine(std::string_view line)
535535
536536 // Check if the command requires arguments
537537 if (cmd.arguments ().size () > 0 && arguments.empty ()) {
538- _printCommandHelp (it->second );
538+ print_help_command (it->second );
539539 return ;
540540 }
541541
@@ -547,14 +547,14 @@ void _processSerialLine(std::string_view line)
547547 SERPR_ERROR (" Command \" %.*s\" not found" , command.size (), command.data ());
548548}
549549
550- void _serialRxTask (void *)
550+ static void task_serial_rx (void *)
551551{
552552 SerialBuffer buffer (32 );
553553
554554 while (true ) {
555- switch (_tryReadSerialLine (buffer)) {
555+ switch (try_read_serial_line (buffer)) {
556556 case SerialReadResult::LineEnd:
557- _processSerialLine (buffer);
557+ process_serial_line (buffer);
558558
559559 // Deallocate memory if the buffer is too large
560560 if (buffer.capacity () > SERIAL_BUFFER_CLEAR_THRESHOLD) {
@@ -564,16 +564,16 @@ void _serialRxTask(void*)
564564 }
565565
566566 // Skip any remaining trailing whitespaces
567- _skipSerialWhitespaces (buffer);
567+ skip_serial_whitespaces (buffer);
568568 break ;
569569 case SerialReadResult::AutoCompleteRequest:
570570 ::Serial.printf (CLEAR_LINE " > %.*s [AutoComplete is not implemented]" , buffer.size (), buffer.data ());
571571 break ;
572572 case SerialReadResult::Data:
573- _echoHandleSerialInput (buffer, true );
573+ echo_handle_serial_input (buffer, true );
574574 break ;
575575 default :
576- _echoHandleSerialInput (buffer, false );
576+ echo_handle_serial_input (buffer, false );
577577 break ;
578578 }
579579
@@ -594,7 +594,7 @@ bool SerialInputHandler::Init()
594594 s_commandGroups = OpenShock::Serial::CommandHandlers::AllCommandHandlers ();
595595 for (const auto & handler : s_commandGroups) {
596596 OS_LOGV (TAG, " Registering command handler: %.*s" , handler.name ().size (), handler.name ().data ());
597- RegisterCommandHandler (handler);
597+ register_command_handler (handler);
598598 }
599599
600600 SerialInputHandler::PrintWelcomeHeader ();
@@ -606,7 +606,7 @@ bool SerialInputHandler::Init()
606606 return false ;
607607 }
608608
609- if (TaskUtils::TaskCreateExpensive (_serialRxTask , " SerialRX" , 10'000 , nullptr , 1 , nullptr ) != pdPASS) { // TODO: Profile stack size
609+ if (TaskUtils::TaskCreateExpensive (task_serial_rx , " SerialRX" , 10'000 , nullptr , 1 , nullptr ) != pdPASS) { // TODO: Profile stack size
610610 OS_LOGE (TAG, " Failed to create serial RX task" );
611611 return false ;
612612 }
0 commit comments