Skip to content

Commit

Permalink
Fixed config
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed May 24, 2024
1 parent e651ece commit ac3e5c2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include <expat.h>
#include <maddy/parser.h> // Markdown -> HTML
#include <mustache.hpp>
#include <nlohmann/json.hpp> // Needs C++11 -std=c++11
#include <nlohmann/json.hpp>

#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/spdlog.h"
Expand Down
9 changes: 5 additions & 4 deletions src/vscp/common/vscp-client-socketcan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ vscpClientSocketCan::~vscpClientSocketCan()
int
vscpClientSocketCan::init(const std::string &interface, const std::string &guid, unsigned long flags, uint32_t timeout)
{
m_interface = interface;
m_interface = interface;
m_guid.getFromString(guid);
m_flags = flags;
setResponseTimeout(DEAULT_RESPONSE_TIMEOUT); // Response timeout 3 ms
Expand Down Expand Up @@ -393,9 +393,7 @@ vscpClientSocketCan::connect(void)
if (pthread_create(&m_threadWork, NULL, workerThread, this)) {
spdlog::critical("SOCKETCAN client: Failed to start workerthread");
return false;
}

m_bConnected = true;
}

return rv;
}
Expand Down Expand Up @@ -880,6 +878,9 @@ workerThread(void *pData)
}
}

// Mark as connected
pObj->setConnected(true);

pthread_mutex_unlock(&pObj->m_mutexSocket);

struct timeval tv;
Expand Down
6 changes: 6 additions & 0 deletions src/vscp/common/vscp-client-socketcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class vscpClientSocketCan : public CVscpClient {
*/
virtual bool isConnected(void);

/*!
Set state of connected flag
@param b True for connected, false for not connected.
*/
void setConnected(bool b=true) {m_bConnected = b;};

/*!
Send VSCP event to remote host.
@return Return VSCP_ERROR_SUCCESS of OK and error code else.
Expand Down
20 changes: 19 additions & 1 deletion src/vscp/common/vscphelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,35 @@

/* byte swapping */

#if !defined(VSCP_UINT16_SWAP_ALWAYS)
#define VSCP_UINT16_SWAP_ALWAYS(val) \
((uint16_t) ((((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | (((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
#endif

#if !defined(VSCP_INT16_SWAP_ALWAYS)
#define VSCP_INT16_SWAP_ALWAYS(val) \
((int16_t) ((((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | (((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
#endif

#if !defined(VSCP_UINT32_SWAP_ALWAYS)
#define VSCP_UINT32_SWAP_ALWAYS(val) \
((uint32_t) ((((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
(((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
(((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
(((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
#endif

#if !defined(VSCP_INT32_SWAP_ALWAYS)
#define VSCP_INT32_SWAP_ALWAYS(val) \
((int32_t) ((((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
(((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
(((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
(((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
#endif

/* machine specific byte swapping */

#if !defined(VSCP_UINT64_SWAP_ALWAYS)
#define VSCP_UINT64_SWAP_ALWAYS(val) \
((uint64_t) ((((uint64_t) (val) & (uint64_t) (0x00000000000000ff)) << 56) | \
(((uint64_t) (val) & (uint64_t) (0x000000000000ff00)) << 40) | \
Expand All @@ -96,7 +106,9 @@
(((uint64_t) (val) & (uint64_t) (0x0000ff0000000000)) >> 24) | \
(((uint64_t) (val) & (uint64_t) (0x00ff000000000000)) >> 40) | \
(((uint64_t) (val) & (uint64_t) (0xff00000000000000)) >> 56)))
#endif

#if !defined(VSCP_INT64_SWAP_ALWAYS)
#define VSCP_INT64_SWAP_ALWAYS(val) \
((int64_t) ((((uint64_t) (val) & (uint64_t) (0x00000000000000ff)) << 56) | \
(((uint64_t) (val) & (uint64_t) (0x000000000000ff00)) << 40) | \
Expand All @@ -106,8 +118,9 @@
(((uint64_t) (val) & (uint64_t) (0x0000ff0000000000)) >> 24) | \
(((uint64_t) (val) & (uint64_t) (0x00ff000000000000)) >> 40) | \
(((uint64_t) (val) & (uint64_t) (0xff00000000000000)) >> 56)))

#endif
#ifdef __BIG_ENDIAN__
#if !defined(VSCP_UINT16_SWAP_ON_BE)
#define VSCP_UINT16_SWAP_ON_BE(val) VSCP_UINT16_SWAP_ALWAYS(val)
#define VSCP_INT16_SWAP_ON_BE(val) VSCP_INT16_SWAP_ALWAYS(val)
#define VSCP_UINT16_SWAP_ON_LE(val) (val)
Expand All @@ -120,7 +133,9 @@
#define VSCP_UINT64_SWAP_ON_LE(val) (val)
#define VSCP_INT64_SWAP_ON_BE(val) VSCP_INT64_SWAP_ALWAYS(val)
#define VSCP_INT64_SWAP_ON_LE(val) (val)
#endif
#else
#if !defined(VSCP_UINT16_SWAP_ON_LE)
#define VSCP_UINT16_SWAP_ON_LE(val) VSCP_UINT16_SWAP_ALWAYS(val)
#define VSCP_INT16_SWAP_ON_LE(val) VSCP_INT16_SWAP_ALWAYS(val)
#define VSCP_UINT16_SWAP_ON_BE(val) (val)
Expand All @@ -134,11 +149,14 @@
#define VSCP_INT64_SWAP_ON_LE(val) VSCP_INT64_SWAP_ALWAYS(val)
#define VSCP_INT64_SWAP_ON_BE(val) (val)
#endif
#endif

#if !defined(Swap8Bytes)
#define Swap8Bytes(val) \
((((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \
(((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | (((val) << 8) & 0x000000FF00000000) | \
(((val) << 24) & 0x0000FF0000000000) | (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000))
#endif

/*!
* @name Min/max macros
Expand Down

0 comments on commit ac3e5c2

Please sign in to comment.