Added board firmware update functionality

This commit is contained in:
Yury Shuvakin
2022-09-13 15:20:09 +03:00
parent d28efef208
commit 4dd1f95193
21 changed files with 908 additions and 225 deletions

View File

@@ -113,8 +113,8 @@ BMSInterface::BMSInterface(QObject *parent) : QObject(parent)
connect(mCommands, SIGNAL(dataToSend(QByteArray&)),this, SLOT(cmdDataToSend(QByteArray&)));
connect(mCommands, SIGNAL(fwVersionReceived(int,int,QString,QByteArray)),this, SLOT(fwVersionReceived(int,int,QString,QByteArray)));
connect(mCommands, SIGNAL(ackReceived(QString)), this, SLOT(ackReceived(QString)));
connect(mbmsConfig, SIGNAL(updated()), this, SLOT(bmsconfUpdated()));
connect(mbmsConfig, SIGNAL(stored()), this, SLOT(bmsconfStored()));
connect(mbmsConfig, SIGNAL(updated()), this, SLOT(bmsConfUpdated()));
connect(mbmsConfig, SIGNAL(stored()), this, SLOT(bmsConfStored()));
}
BMSInterface::~BMSInterface()
@@ -628,7 +628,6 @@ void BMSInterface::ignoreCanChange(bool ignore)
#ifdef HAS_SERIALPORT
void BMSInterface::serialDataAvailable()
{
bool b = true;
while (mSerialPort->bytesAvailable() > 0) {
mPacket->processData(mSerialPort->readAll());
}
@@ -660,7 +659,6 @@ void BMSInterface::serialPortError(QSerialPort::SerialPortError error)
void BMSInterface::tcpInputConnected()
{
bool b = true;
mTcpConnected = true;
updateFwRx(false);
}
@@ -673,7 +671,6 @@ void BMSInterface::tcpInputDisconnected()
void BMSInterface::tcpInputDataAvailable()
{
bool b = true;
while (mTcpSocket->bytesAvailable() > 0) {
mPacket->processData(mTcpSocket->readAll());
}
@@ -748,9 +745,13 @@ void BMSInterface::timerSlot()
if (mIsUploadingFw) {
updateFwRx(false);
mFwRetries = 0;
if (fwStatus.compare("FW Upload Done") == 0) {
if (mCommands->getFirmwareUploadSuccess())
{
disconnectPort();
emit fwUploadStatus(fwStatus, 1.0, false);
} else {
}
else
{
emit fwUploadStatus(fwStatus, 0.0, false);
}
}
@@ -796,7 +797,7 @@ void BMSInterface::fwVersionReceived(int major, int minor, QString hw, QByteArra
{
QList<QPair<int, int> > fwPairs = getSupportedFirmwarePairs();
QString strUuid = Utility::uuid2Str(uuid, true);
QString strUuid = uuid.toHex().toUpper();
if (fwPairs.isEmpty()) {
emit messageDialog(tr("Not Supported Firmwares"),
@@ -862,17 +863,6 @@ void BMSInterface::fwVersionReceived(int major, int minor, QString hw, QByteArra
}
auto fwStr = tr("Firmware version: %1.%2, Hardware: %3, UUID: %4").arg(major).arg(minor).arg(hw).arg(strUuid);
// QString fwStr;
// fwStr.sprintf("ENNOID-BMS Firmware Version %d.%d", major, minor);
// if (!hw.isEmpty()) {
// fwStr += ", Hardware: " + hw;
// }
// if (!strUuid.isEmpty()) {
// fwStr += ", UUID: " + strUuid;
// }
emit statusMessage(fwStr, true);
#if 0
}
@@ -891,13 +881,15 @@ void BMSInterface::fwVersionReceived(int major, int minor, QString hw, QByteArra
}
}
void BMSInterface::bmsconfUpdated()
void BMSInterface::bmsConfUpdated()
{
emit statusMessage(tr("BMS configuration updated"), true);
emit bmsConfigurationUpdated();
}
void BMSInterface::bmsconfStored() {
void BMSInterface::bmsConfStored() {
emit statusMessage(tr("BMS configuration stored to Flash"), true);
emit bmsConfigurationStored();
}
void BMSInterface::ackReceived(QString ackType)