Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdReceiveOnce.cpp
- Revision:
- 14:f9a77400b622
- Parent:
- 1:e52ae6584f1c
diff -r b0f5ae12dc05 -r f9a77400b622 CommandTerminal/CmdReceiveOnce.cpp
--- a/CommandTerminal/CmdReceiveOnce.cpp Fri Nov 04 19:10:24 2016 +0000
+++ b/CommandTerminal/CmdReceiveOnce.cpp Fri Nov 04 14:25:43 2016 -0500
@@ -1,23 +1,26 @@
#include "CmdReceiveOnce.h"
#include "CommandTerminal.h"
-CmdReceiveOnce::CmdReceiveOnce(mDot* dot, mts::MTSSerial& serial) : Command(dot, "Receive Once", "AT+RECV", "Receive and display one packet."),
- _serial(serial)
+CmdReceiveOnce::CmdReceiveOnce() : Command("Receive Once", "AT+RECV", "Receive and display one packet.", "(string:242) or (hex:242)")
+
{
- _help = std::string(text()) + ": " + std::string(desc());
- _usage = "(string:242) or (hex:242)";
}
uint32_t CmdReceiveOnce::action(std::vector<std::string> args)
{
std::vector<uint8_t> data;
- if (_dot->recv(data) == mDot::MDOT_OK) {
- if (_dot->getVerbose())
- _serial.writef("Packet data:\r\n");
-
- if (!data.empty())
- _serial.writef("%s\r\n", CommandTerminal::formatPacketData(data, _dot->getRxOutput()).c_str());
+ if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) {
+ if (!data.empty()) {
+ if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) {
+ for (size_t i = 0; i < data.size(); i++) {
+ CommandTerminal::Serial()->writef("%02x", data[i]);
+ }
+ CommandTerminal::Serial()->writef("\r\n");
+ } else {
+ CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str());
+ }
+ }
}
return 0;
@@ -28,6 +31,6 @@
if (args.size() == 1)
return true;
- setErrorMessage("Invalid arguments");
+ CommandTerminal::setErrorMessage("Invalid arguments");
return false;
}
