Skip to content

Commit

Permalink
pthreads: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansaraev committed Nov 8, 2020
1 parent da44020 commit f25a5a6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 122 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -Wall -std=c++0x $ENV{CXXFLAGS}")
set(DEPLIBS "")

find_package(Threads REQUIRED QUIET)
list(APPEND DEPLIBS ${CMAKE_THREAD_LIBS_INIT})

add_executable(${APP_NAME} ${SOURCES} ${HEADERS})
target_link_libraries(${APP_NAME} ${DEPLIBS})
target_link_libraries(${APP_NAME})

include(GNUInstallDirs)
install (TARGETS ${APP_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
Expand Down
3 changes: 1 addition & 2 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "Version.h"
#include "StopWatch.h"
#include "Defines.h"
#include "Thread.h"
#include "Log.h"
#include "GitVersion.h"

Expand Down Expand Up @@ -597,7 +596,7 @@ int CMMDVMHost::run()
m_ump->clock(ms);

if (ms < 5U)
CThread::sleep(5U);
usleep(5 * 1000);
}

setMode(MODE_QUIT);
Expand Down
15 changes: 7 additions & 8 deletions Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "I2CController.h"
#include "DMRDefines.h"
#include "POCSAGDefines.h"
#include "Thread.h"
#include "Modem.h"
#include "NullModem.h"
#include "Utils.h"
Expand Down Expand Up @@ -238,9 +237,9 @@ void CModem::clock(unsigned int ms)
m_error = true;
close();

CThread::sleep(2000U); // 2s
usleep(2000 * 1000); // 2s
while (!open())
CThread::sleep(5000U); // 5s
usleep(5000 * 1000); // 5s
}

RESP_TYPE_MMDVM type = getResponse();
Expand Down Expand Up @@ -767,7 +766,7 @@ bool CModem::readVersion()
{
assert(m_serial != NULL);

CThread::sleep(2000U); // 2s
usleep(2000 * 1000); // 2s

for (unsigned int i = 0U; i < 6U; i++) {
unsigned char buffer[3U];
Expand All @@ -787,7 +786,7 @@ bool CModem::readVersion()
#endif

for (unsigned int count = 0U; count < MAX_RESPONSES; count++) {
CThread::sleep(10U);
usleep(10 * 1000);
RESP_TYPE_MMDVM resp = getResponse();
if (resp == RTM_OK && m_buffer[2U] == MMDVM_GET_VERSION) {
if (::memcmp(m_buffer + 4U, "MMDVM ", 6U) == 0)
Expand Down Expand Up @@ -816,7 +815,7 @@ bool CModem::readVersion()
}
}

CThread::sleep(1500U);
usleep(1500 * 1000);
}

LogError("Unable to read the firmware version after six attempts");
Expand Down Expand Up @@ -906,7 +905,7 @@ bool CModem::setConfig()
unsigned int count = 0U;
RESP_TYPE_MMDVM resp;
do {
CThread::sleep(10U);
usleep(10 * 1000);

resp = getResponse();
if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) {
Expand Down Expand Up @@ -981,7 +980,7 @@ bool CModem::setFrequency()
unsigned int count = 0U;
RESP_TYPE_MMDVM resp;
do {
CThread::sleep(10U);
usleep(10 * 1000);

resp = getResponse();
if (resp == RTM_OK && m_buffer[2U] != MMDVM_ACK && m_buffer[2U] != MMDVM_NAK) {
Expand Down
4 changes: 3 additions & 1 deletion Nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <ctime>
#include <clocale>

#include <unistd.h>

const unsigned int DMR_RSSI_COUNT = 4U; // 4 * 360ms = 1440ms
const unsigned int DMR_BER_COUNT = 24U; // 24 * 60ms = 1440ms

Expand Down Expand Up @@ -584,5 +586,5 @@ void CNextion::sendCommand(const char* command)
// Since we just firing commands at the display, and not listening for the response,
// we must add a bit of a delay to allow the display to process the commands, else some are getting mangled.
// 10 ms is just a guess, but seems to be sufficient.
CThread::sleep(10U);
usleep(10 * 1000);
}
1 change: 0 additions & 1 deletion Nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "Defines.h"
#include "SerialPort.h"
#include "Timer.h"
#include "Thread.h"
#include <string>

class CNextion : public CDisplay
Expand Down
61 changes: 0 additions & 61 deletions Thread.cpp

This file was deleted.

44 changes: 0 additions & 44 deletions Thread.h

This file was deleted.

0 comments on commit f25a5a6

Please sign in to comment.