Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot-Custom MTS-Serial
Fork of mDot_AT_firmware_CUSTOM by
CmdSerialBaudRate.cpp
00001 #include "CmdSerialBaudRate.h" 00002 00003 CmdSerialBaudRate::CmdSerialBaudRate() : 00004 Command("Serial Baud Rate", "AT+IPR", "Set serial baud rate, default: 115200 ", "(1200,2400,4800,9600,19200,38400,57600,115200,230400,460800,921600)") 00005 { 00006 _queryable = true; 00007 } 00008 00009 uint32_t CmdSerialBaudRate::action(std::vector<std::string> args) 00010 { 00011 if (args.size() == 1) 00012 { 00013 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getBaud()); 00014 } 00015 else if (args.size() == 2) 00016 { 00017 00018 int baudrate = 0; 00019 00020 sscanf(args[1].c_str(), "%d", &baudrate); 00021 00022 if (CommandTerminal::Dot()->setBaud(baudrate) == mDot::MDOT_OK) { 00023 CommandTerminal::Serial()->writef("Set Serial Baud Rate: %lu\r\n", baudrate); 00024 } else { 00025 00026 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00027 return 1; 00028 } 00029 } 00030 00031 return 0; 00032 } 00033 00034 bool CmdSerialBaudRate::verify(std::vector<std::string> args) 00035 { 00036 if (args.size() == 1) 00037 return true; 00038 00039 if (args.size() == 2) { 00040 int baudrate; 00041 00042 if (sscanf(args[1].c_str(), "%d", &baudrate) != 1) { 00043 CommandTerminal::setErrorMessage("Invalid argument"); 00044 return false; 00045 } 00046 00047 return true; 00048 } 00049 00050 CommandTerminal::setErrorMessage("Invalid arguments"); 00051 return false; 00052 }
Generated on Tue Jul 12 2022 20:42:47 by
 1.7.2 
    