firm newest

Dependencies:   MTS-Serial libmDot-dev-mbed5-deprecated

Committer:
nguyenhoang9x5555
Date:
Mon Oct 22 01:56:09 2018 +0000
Revision:
1:c1c6549b9333
Parent:
0:3c869a8cb8f8
hey

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdSerialBaudRate.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2
nguyenhoang9x5555 0:3c869a8cb8f8 3 CmdSerialBaudRate::CmdSerialBaudRate() :
nguyenhoang9x5555 0:3c869a8cb8f8 4 #if defined(TARGET_MTS_MDOT_F411RE)
nguyenhoang9x5555 0:3c869a8cb8f8 5 Command("Serial Baud Rate", "AT+IPR", "Set serial baud rate, default: 115200 ", "(1200,2400,4800,9600,19200,38400,57600,115200,230400,460800,921600)")
nguyenhoang9x5555 0:3c869a8cb8f8 6 #else
nguyenhoang9x5555 0:3c869a8cb8f8 7 Command("Serial Baud Rate", "AT+IPR", "Set serial baud rate, default: 115200 ", "(1200,2400,4800,9600,19200,38400,57600,115200,230400)")
nguyenhoang9x5555 0:3c869a8cb8f8 8 #endif
nguyenhoang9x5555 0:3c869a8cb8f8 9 {
nguyenhoang9x5555 0:3c869a8cb8f8 10 _queryable = true;
nguyenhoang9x5555 0:3c869a8cb8f8 11 }
nguyenhoang9x5555 0:3c869a8cb8f8 12
nguyenhoang9x5555 0:3c869a8cb8f8 13 uint32_t CmdSerialBaudRate::action(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 14 {
nguyenhoang9x5555 0:3c869a8cb8f8 15 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 16 {
nguyenhoang9x5555 0:3c869a8cb8f8 17 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getBaud());
nguyenhoang9x5555 0:3c869a8cb8f8 18 }
nguyenhoang9x5555 0:3c869a8cb8f8 19 else if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 20 {
nguyenhoang9x5555 0:3c869a8cb8f8 21
nguyenhoang9x5555 0:3c869a8cb8f8 22 int baudrate = 0;
nguyenhoang9x5555 0:3c869a8cb8f8 23
nguyenhoang9x5555 0:3c869a8cb8f8 24 sscanf(args[1].c_str(), "%d", &baudrate);
nguyenhoang9x5555 0:3c869a8cb8f8 25
nguyenhoang9x5555 0:3c869a8cb8f8 26 if (CommandTerminal::Dot()->setBaud(baudrate) == mDot::MDOT_OK) {
nguyenhoang9x5555 0:3c869a8cb8f8 27 CommandTerminal::Serial()->writef("Set Serial Baud Rate: %lu\r\n", baudrate);
nguyenhoang9x5555 0:3c869a8cb8f8 28 } else {
nguyenhoang9x5555 0:3c869a8cb8f8 29
nguyenhoang9x5555 0:3c869a8cb8f8 30 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
nguyenhoang9x5555 0:3c869a8cb8f8 31 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 32 }
nguyenhoang9x5555 0:3c869a8cb8f8 33 }
nguyenhoang9x5555 0:3c869a8cb8f8 34
nguyenhoang9x5555 0:3c869a8cb8f8 35 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 36 }
nguyenhoang9x5555 0:3c869a8cb8f8 37
nguyenhoang9x5555 0:3c869a8cb8f8 38 bool CmdSerialBaudRate::verify(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 39 {
nguyenhoang9x5555 0:3c869a8cb8f8 40 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 41 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 42
nguyenhoang9x5555 0:3c869a8cb8f8 43 if (args.size() == 2) {
nguyenhoang9x5555 0:3c869a8cb8f8 44 int baudrate;
nguyenhoang9x5555 0:3c869a8cb8f8 45
nguyenhoang9x5555 0:3c869a8cb8f8 46 if (sscanf(args[1].c_str(), "%d", &baudrate) != 1) {
nguyenhoang9x5555 0:3c869a8cb8f8 47 CommandTerminal::setErrorMessage("Invalid argument");
nguyenhoang9x5555 0:3c869a8cb8f8 48 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 49 }
nguyenhoang9x5555 0:3c869a8cb8f8 50
nguyenhoang9x5555 0:3c869a8cb8f8 51 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 52 }
nguyenhoang9x5555 0:3c869a8cb8f8 53
nguyenhoang9x5555 0:3c869a8cb8f8 54 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 55 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 56 }