添加debug重定向,添加命令行
This commit is contained in:
66
prot/prot_cmdline.h
Normal file
66
prot/prot_cmdline.h
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
#ifndef prot_cmdline_h__
|
||||
#define prot_cmdline_h__
|
||||
|
||||
#include "QObject"
|
||||
#include "base/base.h"
|
||||
#include "QList"
|
||||
#include "interface/codec.h"
|
||||
#include "interface/interface.h"
|
||||
#include "base/mycfg.h"
|
||||
#include "QThread"
|
||||
#include <QNetworkInterface>
|
||||
#include <QUdpSocket>
|
||||
|
||||
// using namespace std;
|
||||
// using namespace std::placeholders;
|
||||
|
||||
// typedef std::function<void(myarray data)> prot_cmdline_cb;
|
||||
typedef void (*prot_cmdline_cb)(QList<myarray> data);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *cmd;
|
||||
const char *help;
|
||||
prot_cmdline_cb fun;
|
||||
} cmdline_def;
|
||||
|
||||
#define cmdline_export(name_, fun_, help_) \
|
||||
const static char __cmdline_##name_##_name[] __attribute__((section(".rodata.cmdlstr"))) = #name_; \
|
||||
const static char __cmdline_##name_##_help[] __attribute__((section(".rodata.cmdlstr"))) = #help_; \
|
||||
__attribute__((used)) static cmdline_def _cmdline_##name_ __attribute__((section("cmdldef"))) = { \
|
||||
.cmd = __cmdline_##name_##_name, \
|
||||
.help = __cmdline_##name_##_help, \
|
||||
.fun = fun_, \
|
||||
}
|
||||
|
||||
class command : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
command()
|
||||
{
|
||||
socket_ = nullptr;
|
||||
}
|
||||
virtual ~command()
|
||||
{
|
||||
if (socket_ != nullptr)
|
||||
delete socket_;
|
||||
}
|
||||
void send(QByteArray data);
|
||||
void init_cb();
|
||||
void ready_read_cb();
|
||||
|
||||
private:
|
||||
QUdpSocket *socket_;
|
||||
QByteArray recv_data;
|
||||
QHostAddress host_addr;
|
||||
quint16 port;
|
||||
};
|
||||
|
||||
|
||||
command *command_start();
|
||||
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user