add request image.

This commit is contained in:
luocai 2024-06-19 16:02:58 +08:00
parent 4724af4086
commit 174e22ea79
6 changed files with 26 additions and 9 deletions

View File

@ -154,7 +154,7 @@ void Application::enroll(const QString &username, uint8_t timeout) {
if (m_communication->currentMessageId() != ModuleCommunication::Idle) { if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
m_communication->reset(); m_communication->reset();
} }
m_communication->enroll(username, timeout); m_communication->enroll(username.toStdString(), timeout);
} }
void Application::deleteUser(uint16_t userid) { void Application::deleteUser(uint16_t userid) {
@ -171,6 +171,13 @@ void Application::deleteAll() {
m_communication->deleteAll(); m_communication->deleteAll();
} }
void Application::getEnrolledImage(const QString &username, uint8_t timeout) {
if (m_communication->currentMessageId() != ModuleCommunication::Idle) {
m_communication->reset();
}
m_communication->enrollEx(username.toStdString(), timeout);
}
ModuleCommunication *Application::module() const { ModuleCommunication *Application::module() const {
return m_communication.get(); return m_communication.get();
} }

View File

@ -46,6 +46,7 @@ public:
Q_INVOKABLE void enroll(const QString &username, uint8_t timeout); Q_INVOKABLE void enroll(const QString &username, uint8_t timeout);
Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteUser(uint16_t userid);
Q_INVOKABLE void deleteAll(); Q_INVOKABLE void deleteAll();
Q_INVOKABLE void getEnrolledImage(const QString &username, uint8_t timeout);
ModuleCommunication *module() const; ModuleCommunication *module() const;
bool connected() const; bool connected() const;
bool uvcOpened() const; bool uvcOpened() const;

View File

@ -67,10 +67,6 @@ void ModuleCommunication::enroll(const std::string &username, uint8_t timeout) {
LOG_CAT(info, GUI) << Separator; LOG_CAT(info, GUI) << Separator;
} }
void ModuleCommunication::enroll(const QString &username, uint8_t timeout) {
return enroll(username.toStdString(), timeout);
}
void ModuleCommunication::enrollEx(const std::string &username, uint8_t timeout) { void ModuleCommunication::enrollEx(const std::string &username, uint8_t timeout) {
EnrollData data = {0}; EnrollData data = {0};
data.timeout = timeout; data.timeout = timeout;
@ -78,7 +74,7 @@ void ModuleCommunication::enrollEx(const std::string &username, uint8_t timeout)
auto [frameData, frameSize] = generateFrame(EnrollGetImage, reinterpret_cast<const uint8_t *>(&data), sizeof(data)); auto [frameData, frameSize] = generateFrame(EnrollGetImage, reinterpret_cast<const uint8_t *>(&data), sizeof(data));
m_serialPort->write(reinterpret_cast<const char *>(frameData), frameSize); m_serialPort->write(reinterpret_cast<const char *>(frameData), frameSize);
LOG_CAT(info, GUI) << "发送注册指令: " << protocolDataFormatString(frameData, frameSize); LOG_CAT(info, GUI) << "发送获取注册照片指令: " << protocolDataFormatString(frameData, frameSize);
LOG_CAT(info, GUI) << "用户名: " << username << ", 超时时间: " << static_cast<int>(timeout) << "s"; LOG_CAT(info, GUI) << "用户名: " << username << ", 超时时间: " << static_cast<int>(timeout) << "s";
LOG_CAT(info, GUI) << Separator; LOG_CAT(info, GUI) << Separator;
} }

View File

@ -83,6 +83,7 @@ public:
}; };
struct EnrolledImageReply { struct EnrolledImageReply {
uint8_t image_format; // 0: 只有Y分量,灰度图
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
uint8_t md5[16]; uint8_t md5[16];
@ -120,8 +121,6 @@ public:
Q_INVOKABLE void reset(); Q_INVOKABLE void reset();
void enroll(const std::string &username, uint8_t timeout); void enroll(const std::string &username, uint8_t timeout);
Q_INVOKABLE void enroll(const QString &username, uint8_t timeout);
void enrollEx(const std::string &username, uint8_t timeout); void enrollEx(const std::string &username, uint8_t timeout);
Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteUser(uint16_t userid);
Q_INVOKABLE void deleteAll(); Q_INVOKABLE void deleteAll();
@ -147,7 +146,6 @@ protected:
void onErrorOccurred(QSerialPort::SerialPortError error); void onErrorOccurred(QSerialPort::SerialPortError error);
std::pair<uint8_t *, uint32_t> generateFrame(MessageId command, const uint8_t *data = nullptr, uint16_t size = 0); std::pair<uint8_t *, uint32_t> generateFrame(MessageId command, const uint8_t *data = nullptr, uint16_t size = 0);
std::string protocolDataFormatString(const uint8_t *data, int size); std::string protocolDataFormatString(const uint8_t *data, int size);
private: private:
std::shared_ptr<QSerialPort> m_serialPort; std::shared_ptr<QSerialPort> m_serialPort;
QByteArray m_receivedBuffer; QByteArray m_receivedBuffer;

View File

@ -101,6 +101,19 @@ ColumnLayout {
} }
} }
} }
GroupBox {
title: "图片注册"
GridLayout {
columns: 1
Button {
text: "录入图片上报"
onClicked: App.getEnrolledImage("",60)
}
Button {
text: "图片下发注册"
}
}
}
Button { Button {
text: "复位" text: "复位"
onClicked: App.module.reset() onClicked: App.module.reset()

View File

@ -59,5 +59,7 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin
./rebuild-app.sh y L015 V200 R002 # 编译烧录固件 ./rebuild-app.sh y L015 V200 R002 # 编译烧录固件
./rebuild-app-ota.sh y L015 V200 R002 11 # 编译OTA固件11为OTA版本号 ./rebuild-app-ota.sh y L015 V200 R002 11 # 编译OTA固件11为OTA版本号
600X800 600X800
./rebuild-app.sh n L021 V901 R001 # 测试新分支的CDC
``` ```