![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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/CmdReceiveContinuous.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 |
1:e52ae6584f1c | 1 | #include "CmdReceiveContinuous.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | #include "CommandTerminal.h" |
Mike Fiore |
1:e52ae6584f1c | 3 | |
Mike Fiore |
14:f9a77400b622 | 4 | CmdReceiveContinuous::CmdReceiveContinuous() |
Mike Fiore |
4:666017851052 | 5 | : |
Mike Fiore |
14:f9a77400b622 | 6 | Command("Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)", "out: (string:242) or (hex:242)") |
Mike Fiore |
14:f9a77400b622 | 7 | { |
Mike Fiore |
1:e52ae6584f1c | 8 | } |
Mike Fiore |
1:e52ae6584f1c | 9 | |
Mike Fiore |
4:666017851052 | 10 | uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 11 | std::vector<uint8_t> data; |
Mike Fiore |
1:e52ae6584f1c | 12 | |
Mike Fiore |
1:e52ae6584f1c | 13 | std::string escape_buffer; |
Mike Fiore |
1:e52ae6584f1c | 14 | char ch; |
Mike Fiore |
1:e52ae6584f1c | 15 | |
Mike Fiore |
4:666017851052 | 16 | while (true) { |
Mike Fiore |
14:f9a77400b622 | 17 | CommandTerminal::Dot()->openRxWindow(0); |
Mike Fiore |
4:666017851052 | 18 | |
Mike Fiore |
4:666017851052 | 19 | osDelay(1000); |
Mike Fiore |
9:ff62b20f7000 | 20 | |
Mike Fiore |
14:f9a77400b622 | 21 | if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 22 | if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) { |
Mike Fiore |
14:f9a77400b622 | 23 | for (size_t i = 0; i < data.size(); i++) { |
Mike Fiore |
14:f9a77400b622 | 24 | CommandTerminal::Serial()->writef("%02x", data[i]); |
Mike Fiore |
14:f9a77400b622 | 25 | } |
Mike Fiore |
14:f9a77400b622 | 26 | CommandTerminal::Serial()->writef("\r\n"); |
Mike Fiore |
14:f9a77400b622 | 27 | } else { |
Mike Fiore |
14:f9a77400b622 | 28 | CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str()); |
Mike Fiore |
14:f9a77400b622 | 29 | } |
Mike Fiore |
1:e52ae6584f1c | 30 | data.clear(); |
Mike Fiore |
1:e52ae6584f1c | 31 | } |
Mike Fiore |
1:e52ae6584f1c | 32 | |
Mike Fiore |
14:f9a77400b622 | 33 | while (CommandTerminal::Serial()->readable()) { |
Mike Fiore |
14:f9a77400b622 | 34 | CommandTerminal::Serial()->read(&ch, 1); |
Mike Fiore |
1:e52ae6584f1c | 35 | escape_buffer += ch; |
Mike Fiore |
14:f9a77400b622 | 36 | if (escape_buffer == CommandTerminal::escape_sequence) { |
Mike Fiore |
14:f9a77400b622 | 37 | CommandTerminal::Dot()->closeRxWindow(); |
Mike Fiore |
1:e52ae6584f1c | 38 | return 0; |
Mike Fiore |
14:f9a77400b622 | 39 | } |
Mike Fiore |
1:e52ae6584f1c | 40 | |
Mike Fiore |
1:e52ae6584f1c | 41 | osDelay(50); |
Mike Fiore |
1:e52ae6584f1c | 42 | } |
Mike Fiore |
1:e52ae6584f1c | 43 | |
Mike Fiore |
1:e52ae6584f1c | 44 | escape_buffer.clear(); |
Mike Fiore |
1:e52ae6584f1c | 45 | } |
Mike Fiore |
1:e52ae6584f1c | 46 | |
Mike Fiore |
1:e52ae6584f1c | 47 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 48 | } |
Mike Fiore |
1:e52ae6584f1c | 49 | |
Mike Fiore |
4:666017851052 | 50 | bool CmdReceiveContinuous::verify(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 51 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 52 | return true; |
Mike Fiore |
1:e52ae6584f1c | 53 | |
Mike Fiore |
14:f9a77400b622 | 54 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 55 | return false; |
Mike Fiore |
1:e52ae6584f1c | 56 | } |