firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdSerialClearOnError.cpp@0:3c869a8cb8f8, 2018-10-18 (annotated)
- Committer:
- nguyenhoang9x5555
- Date:
- Thu Oct 18 04:18:48 2018 +0000
- Revision:
- 0:3c869a8cb8f8
DOT AT FIRMWARE 18102018
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 1 | #include "CmdSerialClearOnError.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdSerialClearOnError::CmdSerialClearOnError() : |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 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)") |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | _queryable = true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 8 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 9 | uint32_t CmdSerialClearOnError::action(std::vector<std::string> args) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 10 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 11 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 12 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 13 | CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getSerialClearOnError()); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | else if (args.size() == 2) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | bool enable = (args[1] == "1"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | if (CommandTerminal::Dot()->setSerialClearOnError(enable) != mDot::MDOT_OK) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | return 1; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 26 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 27 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 28 | bool CmdSerialClearOnError::verify(std::vector<std::string> args) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 29 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 30 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 31 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 32 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 33 | if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 34 | if (args[1] != "1" && args[1] != "0") { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 35 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 36 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 37 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 38 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 39 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 40 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 41 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 42 | CommandTerminal::setErrorMessage("Invalid arguments"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 43 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 44 | } |