![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CmdSendBinary.cpp
00001 #include "CmdSendBinary.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdSendBinary::CmdSendBinary(mDot* dot, mts::MTSSerial& serial) 00005 : 00006 Command(dot, "Send Binary", "AT+SENDB", "Sends supplied binary (hex) packet data one time and return response"), 00007 _serial(serial) { 00008 _help = std::string(text()) + ": " + std::string(desc()); 00009 _usage = "(hex:242)"; 00010 } 00011 00012 uint32_t CmdSendBinary::action(std::vector<std::string> args) { 00013 std::vector<uint8_t> data; 00014 int32_t code; 00015 int temp; 00016 uint32_t length = args[1].size(); 00017 00018 // Convert the ASCII hex data to binary... 00019 for (uint32_t i = 0; i < length; i += 2) { 00020 sscanf(&args[1][i], "%2x", &temp); 00021 data.push_back(temp); 00022 } 00023 00024 if ((code = _dot->send(data, _dot->getTxWait())) != mDot::MDOT_OK) { 00025 std::string error = mDot::getReturnCodeString(code); 00026 00027 if (code != mDot::MDOT_NOT_JOINED) 00028 error += + " - " + _dot->getLastError(); 00029 00030 setErrorMessage(_dot->getLastError());; 00031 return 1; 00032 } 00033 00034 data.clear(); 00035 00036 if (_dot->getTxWait() && _dot->recv(data) == mDot::MDOT_OK) { 00037 if (!data.empty()) { 00038 if (_dot->getVerbose()) 00039 _serial.writef("Packet data:\r\n"); 00040 00041 if (_dot->getRxOutput() == mDot::HEXADECIMAL) { 00042 for (size_t i = 0; i < data.size(); i++) { 00043 _serial.writef("%02x", data[i]); 00044 } 00045 _serial.writef("\r\n"); 00046 } else { 00047 _serial.writef("%s\r\n", CommandTerminal::formatPacketData(data, _dot->getRxOutput()).c_str()); 00048 } 00049 00050 } 00051 } 00052 00053 return 0; 00054 } 00055 00056 bool CmdSendBinary::verify(std::vector<std::string> args) { 00057 if (args.size() == 2) { 00058 if (args[1].size() > 484 || !isHexString(args[1], args[1].size() / 2)) { 00059 setErrorMessage("Invalid hex string, (hex:242)"); 00060 return false; 00061 } 00062 00063 return true; 00064 } 00065 00066 setErrorMessage("Invalid arguments"); 00067 return false; 00068 } 00069
Generated on Tue Jul 12 2022 16:01:23 by
![doxygen](doxygen.png)