Skip to content

Commit e972714

Browse files
committed
added instance names
1 parent 7a6a7c5 commit e972714

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

src/ZeDMDComm.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ ZeDMDComm::ZeDMDComm()
3535

3636
ZeDMDComm::~ZeDMDComm()
3737
{
38-
Log("ZeDMDComm destructor start: connected=%d queue_empty=%d delayed=%d", (int)IsConnected(), (int)IsQueueEmpty(),
39-
(int)m_delayedFrameReady);
38+
Log("ZeDMDComm[%s@%p] destructor start: connected=%d queue_empty=%d delayed=%d", m_instanceName, (void*)this,
39+
(int)IsConnected(), (int)IsQueueEmpty(), (int)m_delayedFrameReady);
4040

4141
m_stopFlag.store(true, std::memory_order_release);
4242
Disconnect();
4343

4444
if (m_pThread)
4545
{
46-
Log("ZeDMDComm destructor: joining run thread");
46+
Log("ZeDMDComm[%s@%p] destructor: joining run thread", m_instanceName, (void*)this);
4747
if (m_pThread->joinable())
4848
{
4949
m_pThread->join();
5050
}
51-
Log("ZeDMDComm destructor: joined run thread");
51+
Log("ZeDMDComm[%s@%p] destructor: joined run thread", m_instanceName, (void*)this);
5252

5353
delete m_pThread;
5454
m_pThread = nullptr;
5555
}
5656

57-
Log("ZeDMDComm destructor finished");
57+
Log("ZeDMDComm[%s@%p] destructor finished", m_instanceName, (void*)this);
5858
}
5959

6060
void ZeDMDComm::SetLogCallback(ZeDMD_LogCallback callback, const void* userData)
@@ -84,7 +84,7 @@ void ZeDMDComm::Run()
8484
m_pThread = new std::thread(
8585
[this]()
8686
{
87-
Log("ZeDMDComm run thread starting");
87+
Log("ZeDMDComm[%s@%p] run thread starting", m_instanceName, (void*)this);
8888
m_stopFlag.load(std::memory_order_acquire);
8989

9090
try
@@ -135,15 +135,15 @@ void ZeDMDComm::Run()
135135
}
136136
}
137137

138-
Log("ZeDMDComm run thread loop exited: connected=%d stop=%d", (int)IsConnected(),
139-
(int)m_stopFlag.load(std::memory_order_relaxed));
138+
Log("ZeDMDComm[%s@%p] run thread loop exited: connected=%d stop=%d", m_instanceName, (void*)this,
139+
(int)IsConnected(), (int)m_stopFlag.load(std::memory_order_relaxed));
140140
}
141141
catch (...)
142142
{
143-
Log("ZeDMDComm run thread caught unexpected exception");
143+
Log("ZeDMDComm[%s@%p] run thread caught unexpected exception", m_instanceName, (void*)this);
144144
}
145145

146-
Log("ZeDMDComm run thread finished");
146+
Log("ZeDMDComm[%s@%p] run thread finished", m_instanceName, (void*)this);
147147
});
148148
}
149149

src/ZeDMDComm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ class ZeDMDComm
265265
void Log(const char* format, ...);
266266

267267
protected:
268+
void SetInstanceName(const char* name)
269+
{
270+
if (!name) return;
271+
const size_t maxLen = sizeof(m_instanceName) - 1;
272+
strncpy(m_instanceName, name, maxLen);
273+
m_instanceName[maxLen] = '\0';
274+
}
275+
268276
virtual bool SendChunks(const uint8_t* pData, uint16_t size);
269277
virtual void Reset();
270278
void ClearFrames();
@@ -314,6 +322,7 @@ class ZeDMDComm
314322
const void* m_logUserData = nullptr;
315323
uint64_t m_zoneHashes[128] = {0};
316324

325+
char m_instanceName[8] = "USB";
317326
char m_ignoredDevices[10][32] = {0};
318327
uint8_t m_ignoredDevicesCounter = 0;
319328
char m_device[32] = {0};

src/ZeDMDSpi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <gpiod.h>
1313
#include <linux/spi/spidev.h>
1414

15-
#if (defined(GPIOD_API_VERSION) && (GPIOD_API_VERSION >= 2)) || (defined(GPIOD_VERSION_MAJOR) && (GPIOD_VERSION_MAJOR >= 2))
15+
#if (defined(GPIOD_API_VERSION) && (GPIOD_API_VERSION >= 2)) || \
16+
(defined(GPIOD_VERSION_MAJOR) && (GPIOD_VERSION_MAJOR >= 2))
1617
#define ZEDMD_GPIOD_API_V2 1
1718
#endif
1819

@@ -29,6 +30,7 @@ class ZeDMDSpi : public ZeDMDComm
2930
public:
3031
ZeDMDSpi() : ZeDMDComm()
3132
{
33+
SetInstanceName("SPI");
3234
m_compression = false;
3335
m_zoneStream = false;
3436
m_keepAliveNotSupported = true;

src/ZeDMDWiFi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class ZeDMDWiFi : public ZeDMDComm
2020
{
2121
public:
22-
ZeDMDWiFi() : ZeDMDComm() {}
22+
ZeDMDWiFi() : ZeDMDComm() { SetInstanceName("WiFi"); }
2323
~ZeDMDWiFi() { Disconnect(); }
2424

2525
virtual bool Connect(const char* name_or_ip);

0 commit comments

Comments
 (0)