AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CmdSerialClearOnError.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 14:f9a77400b622
Added ability to force the AT terminal to use the USB debug port
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 |
14:f9a77400b622 | 3 | CmdSerialClearOnError::CmdSerialClearOnError() : |
Mike Fiore |
14:f9a77400b622 | 4 | Command("Clear On Error", "AT+SDCE", "Serial clear on error if enabled data that cannot be sent will be discarded", "(0:off,1:on)") |
Mike Fiore |
9:ff62b20f7000 | 5 | { |
Mike Fiore |
9:ff62b20f7000 | 6 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 7 | } |
Mike Fiore |
9:ff62b20f7000 | 8 | |
Mike Fiore |
9:ff62b20f7000 | 9 | uint32_t CmdSerialClearOnError::action(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 10 | { |
Mike Fiore |
9:ff62b20f7000 | 11 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 12 | { |
Mike Fiore |
14:f9a77400b622 | 13 | CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getSerialClearOnError()); |
Mike Fiore |
9:ff62b20f7000 | 14 | } |
Mike Fiore |
9:ff62b20f7000 | 15 | else if (args.size() == 2) |
Mike Fiore |
9:ff62b20f7000 | 16 | { |
Mike Fiore |
9:ff62b20f7000 | 17 | bool enable = (args[1] == "1"); |
Mike Fiore |
9:ff62b20f7000 | 18 | |
Mike Fiore |
14:f9a77400b622 | 19 | if (CommandTerminal::Dot()->setSerialClearOnError(enable) != mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 20 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
Mike Fiore |
9:ff62b20f7000 | 21 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 22 | } |
Mike Fiore |
9:ff62b20f7000 | 23 | } |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
9:ff62b20f7000 | 25 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 26 | } |
Mike Fiore |
9:ff62b20f7000 | 27 | |
Mike Fiore |
9:ff62b20f7000 | 28 | bool CmdSerialClearOnError::verify(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 29 | { |
Mike Fiore |
9:ff62b20f7000 | 30 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 31 | return true; |
Mike Fiore |
9:ff62b20f7000 | 32 | |
Mike Fiore |
9:ff62b20f7000 | 33 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 34 | if (args[1] != "1" && args[1] != "0") { |
Mike Fiore |
14:f9a77400b622 | 35 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); |
Mike Fiore |
9:ff62b20f7000 | 36 | return false; |
Mike Fiore |
9:ff62b20f7000 | 37 | } |
Mike Fiore |
9:ff62b20f7000 | 38 | |
Mike Fiore |
9:ff62b20f7000 | 39 | return true; |
Mike Fiore |
9:ff62b20f7000 | 40 | } |
Mike Fiore |
9:ff62b20f7000 | 41 | |
Mike Fiore |
14:f9a77400b622 | 42 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 43 | return false; |
Mike Fiore |
9:ff62b20f7000 | 44 | } |