few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdSerialClearOnError.cpp@11:77b7911263da, 2016-10-25 (annotated)
- Committer:
- serg838
- Date:
- Tue Oct 25 05:39:39 2016 +0000
- Revision:
- 11:77b7911263da
- Parent:
- 9:ff62b20f7000
RTS/CTS changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | #include "CmdSerialClearOnError.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | |
Mike Fiore |
9:ff62b20f7000 | 3 | CmdSerialClearOnError::CmdSerialClearOnError(mDot* dot, mts::MTSSerial& serial) : |
Mike Fiore |
9:ff62b20f7000 | 4 | Command(dot, "Clear On Error", "AT+SDCE", "Serial clear on error if enabled data that cannot be sent will be discarded"), _serial(serial) |
Mike Fiore |
9:ff62b20f7000 | 5 | { |
Mike Fiore |
9:ff62b20f7000 | 6 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
9:ff62b20f7000 | 7 | _usage = "(0:off,1:on)"; |
Mike Fiore |
9:ff62b20f7000 | 8 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 9 | } |
Mike Fiore |
9:ff62b20f7000 | 10 | |
Mike Fiore |
9:ff62b20f7000 | 11 | uint32_t CmdSerialClearOnError::action(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 12 | { |
Mike Fiore |
9:ff62b20f7000 | 13 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 14 | { |
Mike Fiore |
9:ff62b20f7000 | 15 | if (_dot->getVerbose()) |
Mike Fiore |
9:ff62b20f7000 | 16 | _serial.writef("Serial Clear On Error: "); |
Mike Fiore |
9:ff62b20f7000 | 17 | |
Mike Fiore |
9:ff62b20f7000 | 18 | _serial.writef("%d\r\n", _dot->getSerialClearOnError()); |
Mike Fiore |
9:ff62b20f7000 | 19 | } |
Mike Fiore |
9:ff62b20f7000 | 20 | else if (args.size() == 2) |
Mike Fiore |
9:ff62b20f7000 | 21 | { |
Mike Fiore |
9:ff62b20f7000 | 22 | int32_t code; |
Mike Fiore |
9:ff62b20f7000 | 23 | bool enable = (args[1] == "1"); |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
9:ff62b20f7000 | 25 | if ((code = _dot->setSerialClearOnError(enable)) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 26 | setErrorMessage(_dot->getLastError()); |
Mike Fiore |
9:ff62b20f7000 | 27 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 28 | } |
Mike Fiore |
9:ff62b20f7000 | 29 | } |
Mike Fiore |
9:ff62b20f7000 | 30 | |
Mike Fiore |
9:ff62b20f7000 | 31 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 32 | } |
Mike Fiore |
9:ff62b20f7000 | 33 | |
Mike Fiore |
9:ff62b20f7000 | 34 | bool CmdSerialClearOnError::verify(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 35 | { |
Mike Fiore |
9:ff62b20f7000 | 36 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 37 | return true; |
Mike Fiore |
9:ff62b20f7000 | 38 | |
Mike Fiore |
9:ff62b20f7000 | 39 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 40 | if (args[1] != "1" && args[1] != "0") { |
Mike Fiore |
9:ff62b20f7000 | 41 | setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); |
Mike Fiore |
9:ff62b20f7000 | 42 | return false; |
Mike Fiore |
9:ff62b20f7000 | 43 | } |
Mike Fiore |
9:ff62b20f7000 | 44 | |
Mike Fiore |
9:ff62b20f7000 | 45 | return true; |
Mike Fiore |
9:ff62b20f7000 | 46 | } |
Mike Fiore |
9:ff62b20f7000 | 47 | |
Mike Fiore |
9:ff62b20f7000 | 48 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 49 | return false; |
Mike Fiore |
9:ff62b20f7000 | 50 | } |