few changes for RTS/CTS control

Dependencies:   MTS-Serial libmDot mbed-rtos mbed

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdRxOutput.cpp Source File

CmdRxOutput.cpp

00001 #include "CmdRxOutput.h"
00002 
00003 CmdRxOutput::CmdRxOutput(mDot* dot, mts::MTSSerial& serial) :
00004         Command(dot, "Rx Output", "AT+RXO", "Set the Rx output type (0:hexadecimal, 1:raw)"), _serial(serial)
00005 {
00006     _help = std::string(text()) + ": " + std::string(desc());
00007     _usage = "(0,1)";
00008     _queryable = true;
00009 }
00010 
00011 uint32_t CmdRxOutput::action(std::vector<std::string> args)
00012 {
00013     if (args.size() == 1)
00014     {
00015         if (_dot->getVerbose())
00016             _serial.writef("Rx Output: ");
00017 
00018         _serial.writef("%u\r\n", _dot->getRxOutput());
00019     }
00020     else if (args.size() == 2)
00021     {
00022         int32_t code;
00023         uint8_t output = args[1] == "0" ? 0 : 1;
00024         if ((code = _dot->setRxOutput(output)) != mDot::MDOT_OK)
00025         {
00026             
00027             setErrorMessage(_dot->getLastError());;
00028             return 1;
00029         }
00030     }
00031 
00032     return 0;
00033 }
00034 
00035 bool CmdRxOutput::verify(std::vector<std::string> args)
00036 {
00037     if (args.size() == 1)
00038         return true;
00039 
00040     if (args.size() == 2)
00041     {
00042         if (!(args[1] == "0" || args[1] == "1")) {
00043             setErrorMessage("Invalid type, expects (0:hexadecimal, 1:raw)");
00044             return false;
00045         }
00046 
00047         return true;
00048     }
00049 
00050     setErrorMessage("Invalid arguments");
00051     return false;
00052 }