Skip to content

Commit

Permalink
Removed some debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Apr 8, 2024
1 parent a5dc7df commit 408bd5c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
4 changes: 2 additions & 2 deletions resources/linux/vscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"logging": {
"file-enable-log": true,
"file-log-level": "debug",
"file-pattern": "[vscp: %c] [%^%l%$] %v",
"file-pattern": "[vscpd: %c] [%^%l%$] %v",
"file-path": "/var/log/vscp/vscpd.log",
"file-max-size": 5242880,
"file-max-files": 7,
"console-enable-log": true,
"console-log-level": "debug",
"console-pattern": "[vscp: %c] [%^%l%$] %v"
"console-pattern": "[vscpd: %c] [%^%l%$] %v"
},
"mqtt": {
"bind": "",
Expand Down
4 changes: 2 additions & 2 deletions resources/linux/vscpd.json.min-example
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"logging": {
"file-enable-log": true,
"file-log-level": "debug",
"file-pattern": "[vscp: %c] [%^%l%$] %v",
"file-pattern": "[vscpd: %c] [%^%l%$] %v",
"file-path": "/var/log/vscp/vscpd.log",
"file-max-size": 5242880,
"file-max-files": 7,
"console-enable-log": true,
"console-log-level": "debug",
"console-pattern": "[vscp: %c] [%^%l%$] %v"
"console-pattern": "[vscpd: %c] [%^%l%$] %v"
},
"mqtt": {
"host": "test.mosquitto.org",
Expand Down
35 changes: 25 additions & 10 deletions src/vscp/common/register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ vscp_readLevel1RegisterBlock(CVscpClient &client,
return rv;
}

//std::cout << "class=" << (int) ex.vscp_class << " type=" << (int) ex.vscp_type << std::endl << std::flush;
// std::cout << "class=" << (int) ex.vscp_class << " type=" << (int) ex.vscp_type << std::endl << std::flush;

if (VSCP_CLASS1_PROTOCOL == ex.vscp_class) {
if (VSCP_TYPE_PROTOCOL_EXTENDED_PAGE_RESPONSE == ex.vscp_type) {
Expand All @@ -310,21 +310,22 @@ vscp_readLevel1RegisterBlock(CVscpClient &client,

// Another frame received
frameset.erase(ex.data[0]);
//std::cout << "idx=" << (int) ex.data[0] << " left = " << (int) frameset.size() << std::endl << std::flush;
// std::cout << "idx=" << (int) ex.data[0] << " left = " << (int) frameset.size() << std::endl <<
// std::flush;

// Get read data
//printf("size=%d\n", ex.sizeData);
// printf("size=%d\n", ex.sizeData);
for (int i = 0; i < ex.sizeData - 4; i++) {
// values[offset + rcvcnt] = ex.data[4 + i];
values[ex.data[3] + i] = ex.data[4 + i];
rcvcnt++;
}

// Check if we are ready
if ((rcvcnt == count) && frameset.empty()) {
return VSCP_ERROR_SUCCESS;
}

} // if is equal
} // Extended response
} // Protocol
Expand All @@ -340,7 +341,7 @@ vscp_readLevel1RegisterBlock(CVscpClient &client,
#else
usleep(2000);
#endif
printf("l2\n");
//printf("l2\n");
} while (true);

return rv;
Expand Down Expand Up @@ -514,7 +515,9 @@ vscp_scanForDevices(CVscpClient &client, cguid &guidIf, std::set<uint16_t> &foun
uint32_t startTime = vscp_getMsTimeStamp();

while (true) {

uint16_t cnt;

client.getcount(&cnt);
if (cnt) {
rv = client.receive(ex);
Expand All @@ -530,6 +533,12 @@ vscp_scanForDevices(CVscpClient &client, cguid &guidIf, std::set<uint16_t> &foun
rv = VSCP_ERROR_TIMEOUT;
break;
}

#ifdef WIN32
win_usleep(100);
#else
usleep(100);
#endif
}
return VSCP_ERROR_SUCCESS;
}
Expand Down Expand Up @@ -588,35 +597,41 @@ vscp_scanSlowForDevices(CVscpClient &client,
uint32_t startTime = vscp_getMsTimeStamp();

while (true) {

uint16_t cnt;

rv = client.getcount(&cnt);

if (cnt) {
//printf("cnt %d\n", (int) cnt);
// printf("cnt %d\n", (int) cnt);
rv = client.receive(ex);
if (VSCP_ERROR_SUCCESS == rv) {
if ((ex.vscp_class == VSCP_CLASS1_PROTOCOL) && (ex.vscp_type == VSCP_TYPE_PROTOCOL_RW_RESPONSE)) {
//printf("found %d:%d\n", ex.GUID[14], ex.GUID[15]);
// printf("found %d:%d\n", ex.GUID[14], ex.GUID[15]);
found_nodes.insert(ex.GUID[15] + (ex.GUID[14] << 8));
}
else if ((ex.vscp_class == VSCP_CLASS2_LEVEL1_PROTOCOL) && (ex.vscp_type == VSCP_TYPE_PROTOCOL_RW_RESPONSE)) {
//printf("xfound %d:%d\n", ex.GUID[14], ex.GUID[15]);
// printf("xfound %d:%d\n", ex.GUID[14], ex.GUID[15]);
found_nodes.insert(ex.GUID[15] + (ex.GUID[14] << 8));
}
}
}

// If all nodes found we are done
if (found_nodes.size() >= search_nodes.size()) {
printf("done\n");
break;
}

if ((vscp_getMsTimeStamp() - startTime) > timeout) {
// This is no timout we are just done with slow scan
break;
}

#ifdef WIN32
win_usleep(100);
#else
usleep(100);
#endif
}

return VSCP_ERROR_SUCCESS;
Expand Down
10 changes: 10 additions & 0 deletions src/vscp/common/vscp_client_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ workerThread(void *pObj);
int
password_callback(char *buf, int size, int rwflag, void *userdata)
{
// Check pointers
if ((nullptr == buf) || (nullptr == userdata)) {
return 0;
}

vscpClientMqtt *pClient = reinterpret_cast<vscpClientMqtt *>(userdata);

memset(buf, 0, size);
Expand All @@ -106,6 +111,11 @@ mqtt_on_log(struct mosquitto *mosq, void *pData, int level, const char *logmsg)
return;
}

// Check for a valid logmsg pointer
if (nullptr == logmsg) {
return;
}

vscpClientMqtt *pClient = reinterpret_cast<vscpClientMqtt *>(pData);
spdlog::trace("MQTT CLIENT: mqtt_on_log: {}", logmsg);

Expand Down

0 comments on commit 408bd5c

Please sign in to comment.