修改ledset找卡
This commit is contained in:
parent
36433b4d75
commit
b8d679984c
|
@ -6,6 +6,9 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
pcap_t *pcapSend{0};
|
||||
PcapReThread *reThd{0};
|
||||
|
||||
QByteArray getNetDev(QWidget *parent, QByteArray def) {
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
pcap_if_t *devs;
|
||||
|
@ -119,13 +122,11 @@ QByteArray getNetDev(QWidget *parent, QByteArray def) {
|
|||
}
|
||||
|
||||
|
||||
QByteArray sendMsg(QByteArray msg) {
|
||||
return sendMsgNet(msg);
|
||||
int sendMsg(QByteArray msg, const Resp &resp) {
|
||||
return sendMsgNet(msg, resp);
|
||||
}
|
||||
|
||||
QByteArray sendMsgNet(QByteArray msg) {
|
||||
|
||||
|
||||
|
||||
return msg;
|
||||
int sendMsgNet(QByteArray msg, const Resp &resp) {
|
||||
reThd->addResp(resp);
|
||||
return pcap_sendpacket(pcapSend, (u_char*)msg.data(), msg.size());
|
||||
}
|
||||
|
|
|
@ -4,9 +4,15 @@
|
|||
#include <QWidget>
|
||||
#include <QByteArray>
|
||||
|
||||
#include "pcaprethread.h"
|
||||
|
||||
extern pcap_t *pcapSend;
|
||||
extern PcapReThread *reThd;
|
||||
|
||||
|
||||
QByteArray getNetDev(QWidget *parent, QByteArray);
|
||||
|
||||
QByteArray sendMsg(QByteArray);
|
||||
QByteArray sendMsgNet(QByteArray);
|
||||
int sendMsg(QByteArray, const Resp &resp);
|
||||
int sendMsgNet(QByteArray, const Resp &resp);
|
||||
|
||||
#endif // GLOBALFUNC_H
|
||||
|
|
|
@ -160,27 +160,7 @@ MainWin::MainWin() {
|
|||
|
||||
auto btnRefresh = new QPushButton(tr("刷新"));
|
||||
btnRefresh->setMinimumWidth(80);
|
||||
connect(btnRefresh, &QPushButton::clicked, this, [this] {
|
||||
reThd->addResp({0x1E0, [=](const QByteArray data) {
|
||||
if(((u_char)data[10])==0xB0 && data[11]==0 && data[12]==1 && data[13]==1) {
|
||||
auto rr = table->rowCount();
|
||||
table->setRowCount(rr+1);
|
||||
uint32_t virtualVCM = data[6]<<8 | data[7] ;
|
||||
table->setValue(rr, "type", tr("虚拟设备"));
|
||||
table->setValue(rr, "name", tr("网口:")+QString::number(virtualVCM));
|
||||
table->setValue(rr, "link", "千兆网直连");
|
||||
uint32_t vcsNum = data[20] << 24 | data[21] <<16 | data[22] <<8 | data[23] ;
|
||||
table->setValue(rr, "vcs", QString::number(vcsNum));
|
||||
table->setValue(rr, "Pinfo", "P:"+QString::number(virtualVCM));
|
||||
table->setValue(rr, "Oinfo", "备注:可直接配屏,无需发送卡");
|
||||
}
|
||||
}});
|
||||
auto bytes = QByteArray::fromHex("55 55 01 AD 00 01 FF FF FF FF 00 00 00 00 B0 00 01 00 00 00 3B 11 0A 6C 00 00 00 00 21 44 DF 1C");
|
||||
if(pcap_sendpacket(pcapSend, (u_char*)bytes.data(), bytes.size())) {
|
||||
QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
|
||||
return;
|
||||
}
|
||||
});
|
||||
connect(btnRefresh, &QPushButton::clicked, this, &MainWin::getCard);
|
||||
hstatus->addWidget(btnRefresh);
|
||||
|
||||
vBox->addLayout(hstatus);
|
||||
|
@ -204,11 +184,30 @@ MainWin::MainWin() {
|
|||
}
|
||||
}
|
||||
config.endGroup();
|
||||
|
||||
getCard();
|
||||
}
|
||||
|
||||
void MainWin::ProNetData(const u_char *data,int len) {
|
||||
|
||||
|
||||
void MainWin::getCard() {
|
||||
auto msg = QByteArray::fromHex("55 55 01 0D 00 08 FF FF FF FF 00 00 AB CD A0 00 00 00 00 00 38 CB 84 7E 00 00 00 00 00 00 AB CD CD 04 04 46");
|
||||
auto res = sendMsg(msg, {0x10d, [=](const QByteArray data) {
|
||||
if(((u_char)data[10])==0xA0 && data[11]==0 && data[12]==0 && data[13]==0) {
|
||||
auto rr = 0;
|
||||
table->setRowCount(rr+1);
|
||||
uint32_t virtualVCM = data[6]<<8 | data[7] ;
|
||||
table->setValue(rr, "type", tr("虚拟设备"));
|
||||
table->setValue(rr, "name", tr("网口:")+QString::number(virtualVCM));
|
||||
table->setValue(rr, "link", "千兆网直连");
|
||||
uint32_t vcsNum = data[20] << 24 | data[21] <<16 | data[22] <<8 | data[23] ;
|
||||
table->setValue(rr, "vcs", QString::number(vcsNum));
|
||||
table->setValue(rr, "Pinfo", "P:"+QString::number(virtualVCM));
|
||||
table->setValue(rr, "Oinfo", "备注:可直接配屏,无需发送卡");
|
||||
}
|
||||
}});
|
||||
if(res) {
|
||||
QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+pcap_geterr(pcapSend));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "basewin.h"
|
||||
#include "table.h"
|
||||
#include "pcaprethread.h"
|
||||
|
||||
class MainWin : public BaseWin {
|
||||
Q_OBJECT
|
||||
|
@ -11,12 +10,10 @@ public:
|
|||
MainWin();
|
||||
QWidget *win{0};
|
||||
QByteArray net_name;
|
||||
pcap_t *pcapSend{0};
|
||||
PcapReThread *reThd{0};
|
||||
Table *table{0};
|
||||
|
||||
protected slots:
|
||||
void ProNetData(const uint8_t *data, int len);
|
||||
public slots:
|
||||
void getCard();
|
||||
};
|
||||
|
||||
#endif // MAINWIN_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user