Skip to content

Commit

Permalink
enhance connection stability
Browse files Browse the repository at this point in the history
Signed-off-by: huangziyi <[email protected]>
  • Loading branch information
MrThanlon committed Dec 14, 2023
1 parent 88f9588 commit c1191e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
26 changes: 0 additions & 26 deletions src/plugins/openmv/openmvplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2792,32 +2792,6 @@ bool OpenMVPlugin::delayedInitialize()
Tr::tr("Failed to create the documents folder!"));
}

if(Core::EditorManager::currentEditor()
? Core::EditorManager::currentEditor()->document()
? Core::EditorManager::currentEditor()->document()->displayName() == QStringLiteral("helloworld_1.py")
: false
: false)
{
QTimer::singleShot(2000, this, [] {
Utils::CheckableMessageBox::doNotShowAgainInformation(Core::ICore::dialogParent(),
Tr::tr("OpenMV Cam LED Colors"),
Tr::tr("Thanks for using the OpenMV Cam and OpenMV IDE!\n\n"
"Your OpenMV Cam's onboard LED blinks with diffent colors to indicate its state:\n\n"
"Blinking Green:\n\nYour OpenMV Cam's onboard bootloader is running. "
"The onboard bootloader runs for a few seconds when your OpenMV Cam is powered via USB to allow OpenMV IDE to reprogram your OpenMV Cam.\n\n"
"Blinking Blue:\n\nYour OpenMV Cam is running the default main.py script onboard.\n\n"
"If you have an SD card installed or overwrote the main.py script on your OpenMV Cam then it will run whatever code you loaded on it instead.\n\n"
"If the LED is blinking blue but OpenMV IDE can't connect to your OpenMV Cam "
"please make sure you are connecting your OpenMV Cam to your PC with a USB cable that supplies both data and power.\n\n"
"Blinking White:\n\nYour OpenMV Cam's firmware is panicking because of a hardware failure. "
"Please check that your OpenMV Cam's camera module is installed securely.\n\n"),
ExtensionSystem::PluginManager::settings(),
QStringLiteral(DONT_SHOW_LED_STATES_AGAIN),
QDialogButtonBox::Ok,
QDialogButtonBox::Ok);
});
}

return true;
}

Expand Down
20 changes: 13 additions & 7 deletions src/plugins/openmv/openmvpluginserialport.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define WRITE_TIMEOUT 6000
#define SERIAL_READ_TIMEOUT 10000
#define WIFI_READ_TIMEOUT 10000
#define SERIAL_READ_STALL_TIMEOUT 1000
#define SERIAL_READ_STALL_TIMEOUT 2000
#define WIFI_READ_STALL_TIMEOUT 3000
#define BOOTLOADER_WRITE_TIMEOUT 6
#define BOOTLOADER_READ_TIMEOUT 10
Expand Down Expand Up @@ -586,6 +586,7 @@ void OpenMVPluginSerialPort_private::command(const OpenMVPluginSerialPortCommand
QElapsedTimer elaspedTimer2;
elaspedTimer.start();
elaspedTimer2.start();
static unsigned noResponseCount = 0;

do
{
Expand Down Expand Up @@ -656,17 +657,22 @@ void OpenMVPluginSerialPort_private::command(const OpenMVPluginSerialPortCommand

if(response.size() >= responseLen)
{
noResponseCount = 0;
emit commandResult(OpenMVPluginSerialPortCommandResult(true, response.left(command.m_responseLen)));
}
else
{
if(m_port)
{
delete m_port;
m_port = Q_NULLPTR;
noResponseCount += 1;
qDebug() << "no response:" << noResponseCount;
if (noResponseCount > 20) {
if(m_port) {
delete m_port;
m_port = Q_NULLPTR;
}
emit commandResult(OpenMVPluginSerialPortCommandResult(false, QByteArray()));
} else {
emit commandResult(OpenMVPluginSerialPortCommandResult(true, QByteArray()));
}

emit commandResult(OpenMVPluginSerialPortCommandResult(false, QByteArray()));
}
}
}
Expand Down

0 comments on commit c1191e0

Please sign in to comment.