diff --git a/protoDebuger/SerialSelect.qml b/protoDebuger/SerialSelect.qml index 336ee92..085cefa 100644 --- a/protoDebuger/SerialSelect.qml +++ b/protoDebuger/SerialSelect.qml @@ -4,12 +4,20 @@ import QtQuick.Layouts 1.0 Item { + id: serial_select_view objectName: "SerialSelect" width: parent.width - 80 height: parent.height property var comlist: [] visible: true property bool uart_open: false + signal notify(string message) + + Component.onCompleted: { + //信号连接slot signal.connect(id.slot) + console.log(parent) + notify.connect(root.on_notify) + } ColorAnimation { from: "white" @@ -193,12 +201,14 @@ Item { if(ret == 0){ uart_open = true button.text = "关闭串口" + serial_select_view.notify("串口已经连接") } }else{ let ret = DataWrap.closeSerial(); if(ret == 0){ button.text = "打开串口" uart_open = false + serial_select_view.notify("串口已经关闭") } } } diff --git a/protoDebuger/main.qml b/protoDebuger/main.qml index 3cb911b..e1b200a 100644 --- a/protoDebuger/main.qml +++ b/protoDebuger/main.qml @@ -11,13 +11,17 @@ Rectangle { height: 900 visible: true + function on_notify(str){ + status.text = str; + } + Flow{ anchors.fill: parent width: parent.width height: parent.height Rectangle { - width: 80; + width: 100; height: parent.height color: "black" Flow{ @@ -73,7 +77,6 @@ Rectangle { color: "white" font.pointSize: 10 anchors.top: button_net.bottom - } Button{ id: button_proto @@ -102,30 +105,33 @@ Rectangle { } Text { + id: status text: qsTr("未连接") width: parent.width color: "white" - font.pointSize: 10 + font.pointSize: 9 anchors.bottom: parent.bottom + Layout.leftMargin: 10 + Layout.bottomMargin: 10 } } } SerialSelect{ id: uart_choose - width: parent.width - 80 + width: parent.width - 100 height: parent.height } NetSelect{ id: net_choose - width: parent.width - 80 + width: parent.width - 100 height: parent.height } ProtoDebug{ id: proto_debug - width: parent.width - 80 + width: parent.width - 100 height: parent.height visible: false } diff --git a/protoDebuger/serialcontroller.cpp b/protoDebuger/serialcontroller.cpp index f932d22..0bed121 100644 --- a/protoDebuger/serialcontroller.cpp +++ b/protoDebuger/serialcontroller.cpp @@ -63,9 +63,10 @@ int SerialController::SetListener(SerialController::SerialListener *p) mListener = p; } -int SerialController::SendData(uint8_t *data, uint8_t len) +int SerialController::SendData(char *data, uint8_t len) { if(mConnected){ + qDebug()<write((char *)data,len); } return ERROR_SEND; diff --git a/protoDebuger/serialcontroller.h b/protoDebuger/serialcontroller.h index b57c262..7ac3ccc 100644 --- a/protoDebuger/serialcontroller.h +++ b/protoDebuger/serialcontroller.h @@ -44,7 +44,7 @@ public: int SetProto(QSerialProto *); int SetListener(SerialListener *); - int SendData(uint8_t *,uint8_t len); + int SendData(char *,uint8_t len); void GetSetting(QString baudRate, QString dataBits, QString stopBits, QString flow); signals: private: diff --git a/protoDebuger/sharedata.cpp b/protoDebuger/sharedata.cpp index 5f100aa..c6bf166 100644 --- a/protoDebuger/sharedata.cpp +++ b/protoDebuger/sharedata.cpp @@ -63,7 +63,7 @@ int ShareData::ShowDataInQML(QString x) int ShareData::SendUartData(const char *data) { if(nullptr != data){ - this->m_serial_controller_->SendData((uint8_t *)data,strlen(data)); + this->m_serial_controller_->SendData((char *)data,strlen(data)); return 0; } return -1;