1
1
// 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
4
4
//
5
5
//
6
6
// Implementation of N4562 std::experimental::any (merged into C++17) for C++11 compilers.
@@ -7222,6 +7222,21 @@ class LIBCLUON_API EnvelopeConverter {
7222
7222
*/
7223
7223
std::string getProtoEncodedEnvelopeFromJSONWithoutTimeStamps(const std::string &json, int32_t messageIdentifier, uint32_t senderStamp) noexcept;
7224
7224
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
+
7225
7240
private:
7226
7241
std::vector<cluon::MetaMessage> m_listOfMetaMessages{};
7227
7242
std::map<int32_t, cluon::MetaMessage> m_scopeOfMetaMessages{};
@@ -13288,6 +13303,7 @@ inline void ToODVDVisitor::visit(uint32_t id, std::string &&typeName, std::strin
13288
13303
//#include "cluon/MessageParser.hpp"
13289
13304
//#include "cluon/ToJSONVisitor.hpp"
13290
13305
//#include "cluon/ToProtoVisitor.hpp"
13306
+ //#include "cluon/Time.hpp"
13291
13307
//#include "cluon/any/any.hpp"
13292
13308
13293
13309
#include <algorithm>
@@ -13391,6 +13407,18 @@ inline std::string EnvelopeConverter::getJSONFromEnvelope(cluon::data::Envelope
13391
13407
13392
13408
// clang-format off
13393
13409
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 {
13394
13422
// clang-format on
13395
13423
std::string retVal;
13396
13424
if (0 < m_scopeOfMetaMessages.count(messageIdentifier)) {
@@ -13414,7 +13442,10 @@ inline std::string EnvelopeConverter::getProtoEncodedEnvelopeFromJSONWithoutTime
13414
13442
gm.accept(protoEncoder);
13415
13443
13416
13444
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);
13418
13449
13419
13450
retVal = cluon::serializeEnvelope(std::move(env));
13420
13451
}
@@ -14456,9 +14487,7 @@ inline void SharedMemory::initSysV() noexcept {
14456
14487
// set of semaphores and shared memory areas.
14457
14488
std::fstream tokenFile(m_name.c_str(), std::ios::in);
14458
14489
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.
14462
14491
}
14463
14492
tokenFile.close();
14464
14493
@@ -14494,19 +14523,16 @@ inline void SharedMemory::initSysV() noexcept {
14494
14523
// IPC_CREAT flag. On a clean environment, this call must fail
14495
14524
// as there should not be any shared memory segments left.
14496
14525
{
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 );
14498
14527
if (!(orphanedSharedMemoryIDSysV < 0)) {
14499
- std::cerr << "[cluon::SharedMemory (SysV)] Existing shared memory (0x" << std::hex << m_shmKeySysV << std::dec << ") found; ";
14500
14528
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
14504
14530
}
14505
14531
}
14506
14532
}
14507
14533
14508
14534
// 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 );
14510
14536
if (-1 != m_sharedMemoryIDSysV) {
14511
14537
m_sharedMemory = reinterpret_cast<char *>(::shmat(m_sharedMemoryIDSysV, nullptr, 0));
14512
14538
#pragma GCC diagnostic push
@@ -14524,7 +14550,7 @@ inline void SharedMemory::initSysV() noexcept {
14524
14550
}
14525
14551
} else {
14526
14552
// 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 );
14528
14554
if (-1 != m_sharedMemoryIDSysV) {
14529
14555
struct shmid_ds info;
14530
14556
if (-1 != ::shmctl(m_sharedMemoryIDSysV, IPC_STAT, &info)) {
@@ -14562,22 +14588,18 @@ inline void SharedMemory::initSysV() noexcept {
14562
14588
14563
14589
// First, try to remove the orphaned one.
14564
14590
{
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 );
14566
14592
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; ";
14569
14593
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
14573
14595
}
14574
14596
}
14575
14597
}
14576
14598
14577
14599
// Next, create the correct semaphore used as mutex.
14578
14600
{
14579
14601
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 );
14581
14603
if (-1 != m_mutexIDSysV) {
14582
14604
constexpr int NUMBER_OF_SEMAPHORE_TO_CONTROL{0};
14583
14605
constexpr int INITIAL_VALUE{1};
@@ -14598,7 +14620,7 @@ inline void SharedMemory::initSysV() noexcept {
14598
14620
}
14599
14621
}
14600
14622
} 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 );
14602
14624
if (-1 == m_mutexIDSysV) {
14603
14625
std::cerr << "[cluon::SharedMemory (SysV)] Failed to get semaphore (0x" << std::hex << m_mutexKeySysV << std::dec // LCOV_EXCL_LINE
14604
14626
<< ", intended to use as mutex): " << ::strerror(errno) << " (" << errno << ")" << std::endl; // LCOV_EXCL_LINE
@@ -14618,22 +14640,18 @@ inline void SharedMemory::initSysV() noexcept {
14618
14640
14619
14641
// First, try to remove the orphaned one.
14620
14642
{
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 );
14622
14644
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; ";
14625
14645
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
14629
14647
}
14630
14648
}
14631
14649
}
14632
14650
14633
14651
// Next, create the correct semaphore used as condition variable.
14634
14652
{
14635
14653
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 );
14637
14655
if (-1 != m_conditionIDSysV) {
14638
14656
constexpr int NUMBER_OF_SEMAPHORE_TO_CONTROL{0};
14639
14657
constexpr int INITIAL_VALUE{1};
@@ -14654,7 +14672,7 @@ inline void SharedMemory::initSysV() noexcept {
14654
14672
}
14655
14673
}
14656
14674
} 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 );
14658
14676
if (-1 == m_conditionIDSysV) {
14659
14677
std::cerr << "[cluon::SharedMemory (SysV)] Failed to get semaphore (0x" << std::hex << m_conditionKeySysV << std::dec // LCOV_EXCL_LINE
14660
14678
<< ", 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) {
16673
16691
if (od4 && !od4->isRunning()) {
16674
16692
break;
16675
16693
}
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
+ }
16676
16698
// Check for broadcasting status updates.
16677
16699
if (playerStatusUpdate) {
16678
16700
std::string s;
0 commit comments