Skip to content

Commit

Permalink
[fixed] #40 CSerialPortDemoNoGui high CPU usage problem
Browse files Browse the repository at this point in the history
Signed-off-by: itas109 <itas109@qq.com>
  • Loading branch information
itas109 committed Nov 22, 2020
1 parent db97eb9 commit 3958c45
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions examples/CommNoGui/CSerialPortDemoNoGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPortInfo.h"

#ifdef _WIN32
#include <windows.h>
#define imsleep(microsecond) Sleep(microsecond) // ms
#else
#include <unistd.h>
#define imsleep(microsecond) usleep(1000 * microsecond) // ms
#endif

#include <vector>
using namespace itas109;
using namespace std;
Expand Down Expand Up @@ -119,8 +127,11 @@ int main()
//write
sp.writeData("itas109", 7);

while (true);
}
for (;;)
{
imsleep(1);
}
}

return 0;
}

0 comments on commit 3958c45

Please sign in to comment.