Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit e5f61ad

Browse files
committed
* Upgrade to libcluon v0.0.108
Signed-off-by: Christian Berger <christian.berger@gu.se>
1 parent 94eeaab commit e5f61ad

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ project(opendlv-device-camera-v4l)
1919

2020
################################################################################
2121
# Defining the relevant version of libcluon.
22-
set(CLUON_COMPLETE cluon-complete-v0.0.105.hpp)
22+
set(CLUON_COMPLETE cluon-complete-v0.0.108.hpp)
2323

2424
################################################################################
2525
# Set the search path for .cmake files.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To run this microservice using our pre-built Docker multi-arch images to open
4242
a Video4Linux-supported camera, simply start it as follows:
4343

4444
```
45-
docker run --rm -ti --init --ipc=host -v /tmp:/tmp -e DISPLAY=$DISPLAY --device /dev/video0 chalmersrevere/opendlv-device-camera-v4l-multi:v0.0.5 --camera=/dev/video0 --width=640 --height=480 --freq=20 --verbose
45+
docker run --rm -ti --init --ipc=host -v /tmp:/tmp -e DISPLAY=$DISPLAY --device /dev/video0 chalmersrevere/opendlv-device-camera-v4l-multi:v0.0.6 --camera=/dev/video0 --width=640 --height=480 --freq=20 --verbose
4646
```
4747

4848
## Build from sources on the example of Ubuntu 16.04 LTS

src/cluon-complete-v0.0.105.hpp renamed to src/cluon-complete-v0.0.108.hpp

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is an auto-generated header-only single-file distribution of libcluon.
2-
// Date: Thu, 19 Jul 2018 20:35:46 +0200
3-
// Version: 0.0.105
2+
// Date: Mon, 13 Aug 2018 19:56:15 +0200
3+
// Version: 0.0.108
44
//
55
//
66
// Implementation of N4562 std::experimental::any (merged into C++17) for C++11 compilers.
@@ -7222,6 +7222,21 @@ class LIBCLUON_API EnvelopeConverter {
72227222
*/
72237223
std::string getProtoEncodedEnvelopeFromJSONWithoutTimeStamps(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp) noexcept;
72247224

7225+
/**
7226+
* This method transforms a given JSON representation into a Proto-encoded Envelope
7227+
* including the prepended OD4-header and setting cluon::time::now() as sampleTimeStamp.
7228+
*
7229+
* @param json representation according to the given message specification.
7230+
* @param messageIdentifier The given JSON representation shall be interpreted
7231+
* as the specified message.
7232+
* @param senderStamp to be used in the Envelope.
7233+
* @return Proto-encoded Envelope including OD4-header or empty string.
7234+
*/
7235+
std::string getProtoEncodedEnvelopeFromJSON(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp) noexcept;
7236+
7237+
private:
7238+
std::string getProtoEncodedEnvelopeFromJSON(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp, cluon::data::TimeStamp sampleTimeStamp) noexcept;
7239+
72257240
private:
72267241
std::vector<cluon::MetaMessage> m_listOfMetaMessages{};
72277242
std::map<int32_t, cluon::MetaMessage> m_scopeOfMetaMessages{};
@@ -13288,6 +13303,7 @@ inline void ToODVDVisitor::visit(uint32_t id, std::string &&typeName, std::strin
1328813303
//#include "cluon/MessageParser.hpp"
1328913304
//#include "cluon/ToJSONVisitor.hpp"
1329013305
//#include "cluon/ToProtoVisitor.hpp"
13306+
//#include "cluon/Time.hpp"
1329113307
//#include "cluon/any/any.hpp"
1329213308

1329313309
#include <algorithm>
@@ -13391,6 +13407,18 @@ inline std::string EnvelopeConverter::getJSONFromEnvelope(cluon::data::Envelope
1339113407

1339213408
// clang-format off
1339313409
inline std::string EnvelopeConverter::getProtoEncodedEnvelopeFromJSONWithoutTimeStamps(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp) noexcept {
13410+
// clang-format on
13411+
return getProtoEncodedEnvelopeFromJSON(json, messageIdentifier, senderStamp, cluon::data::TimeStamp());
13412+
}
13413+
13414+
// clang-format off
13415+
inline std::string EnvelopeConverter::getProtoEncodedEnvelopeFromJSON(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp) noexcept {
13416+
// clang-format on
13417+
return getProtoEncodedEnvelopeFromJSON(json, messageIdentifier, senderStamp, cluon::time::now());
13418+
}
13419+
13420+
// clang-format off
13421+
inline std::string EnvelopeConverter::getProtoEncodedEnvelopeFromJSON(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp, cluon::data::TimeStamp sampleTimeStamp) noexcept {
1339413422
// clang-format on
1339513423
std::string retVal;
1339613424
if (0 < m_scopeOfMetaMessages.count(messageIdentifier)) {
@@ -13414,7 +13442,10 @@ inline std::string EnvelopeConverter::getProtoEncodedEnvelopeFromJSONWithoutTime
1341413442
gm.accept(protoEncoder);
1341513443

1341613444
cluon::data::Envelope env;
13417-
env.dataType(messageIdentifier).serializedData(protoEncoder.encodedData()).senderStamp(senderStamp);
13445+
env.dataType(messageIdentifier)
13446+
.serializedData(protoEncoder.encodedData())
13447+
.senderStamp(senderStamp)
13448+
.sampleTimeStamp(sampleTimeStamp);
1341813449

1341913450
retVal = cluon::serializeEnvelope(std::move(env));
1342013451
}
@@ -14456,9 +14487,7 @@ inline void SharedMemory::initSysV() noexcept {
1445614487
// set of semaphores and shared memory areas.
1445714488
std::fstream tokenFile(m_name.c_str(), std::ios::in);
1445814489
if (tokenFile.good()) {
14459-
std::cerr << "[cluon::SharedMemory (SysV)] Token file '" << m_name << "' already exists; need to clean up existing SysV-based shared memory."
14460-
<< std::endl;
14461-
// Cleaning up will be tried in the code below.
14490+
// Existing tokenFile found. Cleaning up will be tried in the code below.
1446214491
}
1446314492
tokenFile.close();
1446414493

@@ -14494,19 +14523,16 @@ inline void SharedMemory::initSysV() noexcept {
1449414523
// IPC_CREAT flag. On a clean environment, this call must fail
1449514524
// as there should not be any shared memory segments left.
1449614525
{
14497-
int orphanedSharedMemoryIDSysV = ::shmget(m_shmKeySysV, 0, S_IRUSR | S_IWUSR);
14526+
int orphanedSharedMemoryIDSysV = ::shmget(m_shmKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1449814527
if (!(orphanedSharedMemoryIDSysV < 0)) {
14499-
std::cerr << "[cluon::SharedMemory (SysV)] Existing shared memory (0x" << std::hex << m_shmKeySysV << std::dec << ") found; ";
1450014528
if (::shmctl(orphanedSharedMemoryIDSysV, IPC_RMID, 0)) {
14501-
std::cerr << "removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
14502-
} else {
14503-
std::cerr << "successfully removed." << std::endl;
14529+
std::cerr << "[cluon::SharedMemory (SysV)] Existing shared memory (0x" << std::hex << m_shmKeySysV << std::dec << ") found; removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
1450414530
}
1450514531
}
1450614532
}
1450714533

1450814534
// Now, create the shared memory segment.
14509-
m_sharedMemoryIDSysV = ::shmget(m_shmKeySysV, m_size, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
14535+
m_sharedMemoryIDSysV = ::shmget(m_shmKeySysV, m_size, IPC_CREAT | IPC_EXCL | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1451014536
if (-1 != m_sharedMemoryIDSysV) {
1451114537
m_sharedMemory = reinterpret_cast<char *>(::shmat(m_sharedMemoryIDSysV, nullptr, 0));
1451214538
#pragma GCC diagnostic push
@@ -14524,7 +14550,7 @@ inline void SharedMemory::initSysV() noexcept {
1452414550
}
1452514551
} else {
1452614552
// The caller wants to attach to an existing shared memory segment.
14527-
m_sharedMemoryIDSysV = ::shmget(m_shmKeySysV, 0, S_IRUSR | S_IWUSR);
14553+
m_sharedMemoryIDSysV = ::shmget(m_shmKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1452814554
if (-1 != m_sharedMemoryIDSysV) {
1452914555
struct shmid_ds info;
1453014556
if (-1 != ::shmctl(m_sharedMemoryIDSysV, IPC_STAT, &info)) {
@@ -14562,22 +14588,18 @@ inline void SharedMemory::initSysV() noexcept {
1456214588

1456314589
// First, try to remove the orphaned one.
1456414590
{
14565-
int orphanedMutexIDSysV = ::semget(m_mutexKeySysV, 0, S_IRUSR | S_IWUSR);
14591+
int orphanedMutexIDSysV = ::semget(m_mutexKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1456614592
if (!(orphanedMutexIDSysV < 0)) {
14567-
std::cerr << "[cluon::SharedMemory (SysV)] Existing semaphore (0x" << std::hex << m_mutexKeySysV << std::dec
14568-
<< ", intended to use as mutex) found; ";
1456914593
if (::semctl(orphanedMutexIDSysV, 0, IPC_RMID)) {
14570-
std::cerr << "removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
14571-
} else {
14572-
std::cerr << "successfully removed." << std::endl;
14594+
std::cerr << "[cluon::SharedMemory (SysV)] Existing semaphore (0x" << std::hex << m_mutexKeySysV << std::dec << ", intended to use as mutex) found; removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
1457314595
}
1457414596
}
1457514597
}
1457614598

1457714599
// Next, create the correct semaphore used as mutex.
1457814600
{
1457914601
constexpr int NSEMS{1};
14580-
m_mutexIDSysV = ::semget(m_mutexKeySysV, NSEMS, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
14602+
m_mutexIDSysV = ::semget(m_mutexKeySysV, NSEMS, IPC_CREAT | IPC_EXCL | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1458114603
if (-1 != m_mutexIDSysV) {
1458214604
constexpr int NUMBER_OF_SEMAPHORE_TO_CONTROL{0};
1458314605
constexpr int INITIAL_VALUE{1};
@@ -14598,7 +14620,7 @@ inline void SharedMemory::initSysV() noexcept {
1459814620
}
1459914621
}
1460014622
} else {
14601-
m_mutexIDSysV = ::semget(m_mutexKeySysV, 0, S_IRUSR | S_IWUSR);
14623+
m_mutexIDSysV = ::semget(m_mutexKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1460214624
if (-1 == m_mutexIDSysV) {
1460314625
std::cerr << "[cluon::SharedMemory (SysV)] Failed to get semaphore (0x" << std::hex << m_mutexKeySysV << std::dec // LCOV_EXCL_LINE
1460414626
<< ", intended to use as mutex): " << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
@@ -14618,22 +14640,18 @@ inline void SharedMemory::initSysV() noexcept {
1461814640

1461914641
// First, try to remove the orphaned one.
1462014642
{
14621-
int orphanedConditionIDSysV = ::semget(m_conditionKeySysV, 0, S_IRUSR | S_IWUSR);
14643+
int orphanedConditionIDSysV = ::semget(m_conditionKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1462214644
if (!(orphanedConditionIDSysV < 0)) {
14623-
std::cerr << "[cluon::SharedMemory (SysV)] Existing semaphore (0x" << std::hex << m_conditionKeySysV << std::dec
14624-
<< ", intended to use as condition variable) found; ";
1462514645
if (::semctl(orphanedConditionIDSysV, 0, IPC_RMID)) {
14626-
std::cerr << "removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
14627-
} else {
14628-
std::cerr << "successfully removed." << std::endl;
14646+
std::cerr << "[cluon::SharedMemory (SysV)] Existing semaphore (0x" << std::hex << m_conditionKeySysV << std::dec << ", intended to use as condition variable) found; removing failed." << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
1462914647
}
1463014648
}
1463114649
}
1463214650

1463314651
// Next, create the correct semaphore used as condition variable.
1463414652
{
1463514653
constexpr int NSEMS{1};
14636-
m_conditionIDSysV = ::semget(m_conditionKeySysV, NSEMS, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
14654+
m_conditionIDSysV = ::semget(m_conditionKeySysV, NSEMS, IPC_CREAT | IPC_EXCL | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1463714655
if (-1 != m_conditionIDSysV) {
1463814656
constexpr int NUMBER_OF_SEMAPHORE_TO_CONTROL{0};
1463914657
constexpr int INITIAL_VALUE{1};
@@ -14654,7 +14672,7 @@ inline void SharedMemory::initSysV() noexcept {
1465414672
}
1465514673
}
1465614674
} else {
14657-
m_conditionIDSysV = ::semget(m_conditionKeySysV, 0, S_IRUSR | S_IWUSR);
14675+
m_conditionIDSysV = ::semget(m_conditionKeySysV, 0, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
1465814676
if (-1 == m_conditionIDSysV) {
1465914677
std::cerr << "[cluon::SharedMemory (SysV)] Failed to get semaphore (0x" << std::hex << m_conditionKeySysV << std::dec // LCOV_EXCL_LINE
1466014678
<< ", intended to use as condition variable): " << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
@@ -16673,6 +16691,10 @@ inline int32_t cluon_replay(int32_t argc, char **argv) {
1667316691
if (od4 && !od4->isRunning()) {
1667416692
break;
1667516693
}
16694+
// If we are at the end of the playback file, simply wait a little to avoid excessive system load.
16695+
if (!player.hasMoreData() && keepRunning) {
16696+
std::this_thread::sleep_for(std::chrono::duration<int32_t, std::milli>(200)); // LCOV_EXCL_LINE
16697+
}
1667616698
// Check for broadcasting status updates.
1667716699
if (playerStatusUpdate) {
1667816700
std::string s;

0 commit comments

Comments
 (0)