Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 062ecb5

Browse files
committed
Merge pull request #353 from NicoHood/patch-1
Fix RS232 reconnect bug
2 parents e93bd2f + d527e32 commit 062ecb5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libsrc/leddevice/LedRs232Device.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ int LedRs232Device::writeBytes(const unsigned size, const uint8_t * data)
6464

6565
if (!_rs232Port.isOpen())
6666
{
67-
return -1;
67+
// try to reopen
68+
int status = open();
69+
if(status == -1){
70+
// Try again in 3 seconds
71+
int seconds = 3000;
72+
_blockedForDelay = true;
73+
QTimer::singleShot(seconds, this, SLOT(unblockAfterDelay()));
74+
std::cout << "Device blocked for " << seconds << " ms" << std::endl;
75+
}
76+
return status;
6877
}
6978

7079
// for (int i = 0; i < 20; ++i)

0 commit comments

Comments
 (0)