summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Elder <aelder@audioscience.com>2015-12-01 10:25:33 -0500
committerAndrew Elder <aelder@audioscience.com>2015-12-01 12:01:09 -0500
commit275c51f883de235124012ef62b9689938cf93482 (patch)
tree6f3426100b18996028ee944c0469ab3739c855e0
parent50cd6e0d613aa212212eeaa570a71ae6bc247dbd (diff)
downloadOpen-AVB-275c51f883de235124012ef62b9689938cf93482.tar.gz
gPTP: common: replace all fprintf() calls with XPTPD_PRINTF() macro. Issue #321
-rw-r--r--daemons/gptp/common/avbts_clock.hpp2
-rw-r--r--daemons/gptp/common/avbts_port.hpp2
-rw-r--r--daemons/gptp/common/ieee1588clock.cpp12
-rw-r--r--daemons/gptp/common/ieee1588port.cpp21
-rw-r--r--daemons/gptp/common/ptp_message.cpp38
5 files changed, 36 insertions, 39 deletions
diff --git a/daemons/gptp/common/avbts_clock.hpp b/daemons/gptp/common/avbts_clock.hpp
index f9611059..53508d84 100644
--- a/daemons/gptp/common/avbts_clock.hpp
+++ b/daemons/gptp/common/avbts_clock.hpp
@@ -248,7 +248,7 @@ public:
*/
void setGrandmasterClockIdentity(ClockIdentity id) {
if (id != grandmaster_clock_identity) {
- fprintf(stderr, "New Grandmaster \"%s\" (previous \"%s\")\n", id.getIdentityString().c_str(), grandmaster_clock_identity.getIdentityString().c_str());
+ XPTPD_PRINTF("New Grandmaster \"%s\" (previous \"%s\")\n", id.getIdentityString().c_str(), grandmaster_clock_identity.getIdentityString().c_str());
grandmaster_clock_identity = id;
}
}
diff --git a/daemons/gptp/common/avbts_port.hpp b/daemons/gptp/common/avbts_port.hpp
index 13694f10..43defc2f 100644
--- a/daemons/gptp/common/avbts_port.hpp
+++ b/daemons/gptp/common/avbts_port.hpp
@@ -380,7 +380,7 @@ class IEEE1588Port {
*/
void setAsCapable(bool ascap) {
if (ascap != asCapable) {
- fprintf(stderr, "AsCapable: %s\n",
+ XPTPD_PRINTF("AsCapable: %s\n",
ascap == true ? "Enabled" : "Disabled");
}
if(!ascap){
diff --git a/daemons/gptp/common/ieee1588clock.cpp b/daemons/gptp/common/ieee1588clock.cpp
index 6e090880..525b9771 100644
--- a/daemons/gptp/common/ieee1588clock.cpp
+++ b/daemons/gptp/common/ieee1588clock.cpp
@@ -417,14 +417,14 @@ bool IEEE1588Clock::isBetterThan(PTPMessageAnnounce * msg)
msg->getGrandmasterIdentity((char *)that1 + 6);
#if 0
- fprintf(stderr, "(Clk)Us: ");
+ XPTPD_PRINTF("(Clk)Us: ");
for (int i = 0; i < 14; ++i)
- fprintf(stderr, "%hhx ", this1[i]);
- fprintf(stderr, "\n");
- fprintf(stderr, "(Clk)Them: ");
+ XPTPD_PRINTF("%hhx ", this1[i]);
+ XPTPD_PRINTF("\n");
+ XPTPD_PRINTF("(Clk)Them: ");
for (int i = 0; i < 14; ++i)
- fprintf(stderr, "%hhx ", that1[i]);
- fprintf(stderr, "\n");
+ XPTPD_PRINTF("%hhx ", that1[i]);
+ XPTPD_PRINTF("\n");
#endif
return (memcmp(this1, that1, 14) < 0) ? true : false;
diff --git a/daemons/gptp/common/ieee1588port.cpp b/daemons/gptp/common/ieee1588port.cpp
index a52f7967..090beaca 100644
--- a/daemons/gptp/common/ieee1588port.cpp
+++ b/daemons/gptp/common/ieee1588port.cpp
@@ -397,7 +397,7 @@ void IEEE1588Port::processEvent(Event e)
}
if( port_state != PTP_SLAVE && port_state != PTP_MASTER ) {
- fprintf( stderr, "Starting PDelay\n" );
+ XPTPD_PRINTF("Starting PDelay\n" );
startPDelay();
}
@@ -570,8 +570,7 @@ void IEEE1588Port::processEvent(Event e)
|| port_state == PTP_UNCALIBRATED
|| port_state == PTP_SLAVE
|| port_state == PTP_PRE_MASTER) {
- fprintf
- (stderr,
+ XPTPD_PRINTF(
"*** %s Timeout Expired - Becoming Master\n",
e == ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ? "Announce" :
"Sync" );
@@ -653,8 +652,7 @@ void IEEE1588Port::processEvent(Event e)
timer->sleep(req);
wait_time += req;
if (ts_good != GPTP_EC_EAGAIN && iter < 1)
- fprintf
- (stderr,
+ XPTPD_PRINTF(
"Error (TX) timestamping PDelay request "
"(Retrying-%d), error=%d\n", iter, ts_good);
ts_good =
@@ -670,7 +668,7 @@ void IEEE1588Port::processEvent(Event e)
} else {
Timestamp failed = INVALID_TIMESTAMP;
pdelay_req->setTimestamp(failed);
- fprintf( stderr, "Invalid TX\n" );
+ XPTPD_PRINTF( "Invalid TX\n" );
}
if (ts_good != GPTP_EC_SUCCESS) {
@@ -769,8 +767,7 @@ void IEEE1588Port::processEvent(Event e)
char msg
[HWTIMESTAMPER_EXTENDED_MESSAGE_SIZE];
getExtendedError(msg);
- fprintf
- (stderr,
+ XPTPD_PRINTF(
"Error (TX) timestamping Sync, error="
"%d\n%s",
ts_good, msg );
@@ -871,7 +868,7 @@ void IEEE1588Port::processEvent(Event e)
case PDELAY_DEFERRED_PROCESSING:
pdelay_rx_lock->lock();
if (last_pdelay_resp_fwup == NULL) {
- fprintf(stderr, "PDelay Response Followup is NULL!\n");
+ XPTPD_PRINTF("PDelay Response Followup is NULL!\n");
abort();
}
last_pdelay_resp_fwup->processMessage(this);
@@ -935,7 +932,7 @@ void IEEE1588Port::becomeMaster( bool annc ) {
startAnnounce();
}
clock->addEventTimer( this, SYNC_INTERVAL_TIMEOUT_EXPIRES, 16000000 );
- fprintf( stderr, "Switching to Master\n" );
+ XPTPD_PRINTF("Switching to Master\n" );
return;
}
@@ -955,7 +952,7 @@ void IEEE1588Port::becomeSlave( bool restart_syntonization ) {
(ANNOUNCE_RECEIPT_TIMEOUT_MULTIPLIER*
(unsigned long long)
(pow((double)2,getAnnounceInterval())*1000000000.0)));
- fprintf( stderr, "Switching to Slave\n" );
+ XPTPD_PRINTF("Switching to Slave\n" );
if( restart_syntonization ) clock->newSyntonizationSetPoint();
return;
@@ -981,7 +978,7 @@ void IEEE1588Port::recommendState
reset_sync = true;
} else {
if( changed_external_master ) {
- fprintf( stderr, "Changed master!\n" );
+ XPTPD_PRINTF("Changed master!\n" );
clock->newSyntonizationSetPoint();
reset_sync = true;
}
diff --git a/daemons/gptp/common/ptp_message.cpp b/daemons/gptp/common/ptp_message.cpp
index ec2bc702..a40690cc 100644
--- a/daemons/gptp/common/ptp_message.cpp
+++ b/daemons/gptp/common/ptp_message.cpp
@@ -83,12 +83,12 @@ PTPMessageCommon *buildPTPMessage
int i;
XPTPD_INFO("Packet Dump:\n");
for (i = 0; i < size; ++i) {
- fprintf(stderr, "%hhx\t", buf[i]);
+ XPTPD_PRINTF("%hhx\t", buf[i]);
if (i % 8 == 7)
- fprintf(stderr, "\n");
+ XPTPD_PRINTF("\n");
}
if (i % 8 != 0)
- fprintf(stderr, "\n");
+ XPTPD_PRINTF("\n");
}
#endif
@@ -124,8 +124,8 @@ PTPMessageCommon *buildPTPMessage
// Waits at least 1 time slice regardless of size of 'req'
timer->sleep(req);
if (ts_good != GPTP_EC_EAGAIN)
- fprintf
- ( stderr, "Error (RX) timestamping RX event packet (Retrying), error=%d\n",
+ XPTPD_PRINTF(
+ "Error (RX) timestamping RX event packet (Retrying), error=%d\n",
ts_good );
ts_good =
port->getRxTimestamp(sourcePortIdentity, sequenceId,
@@ -157,8 +157,8 @@ PTPMessageCommon *buildPTPMessage
switch (messageType) {
case SYNC_MESSAGE:
- //fprintf( stderr, "*** Received Sync message\n" );
- //printf( "Sync RX timestamp = %hu,%u,%u\n", timestamp.seconds_ms, timestamp.seconds_ls, timestamp.nanoseconds );
+ //XPTPD_PRINTF("*** Received Sync message\n" );
+ //XPTPD_PRINTF("Sync RX timestamp = %hu,%u,%u\n", timestamp.seconds_ms, timestamp.seconds_ls, timestamp.nanoseconds );
XPTPD_INFO("*** Received Sync message");
// Be sure buffer is the correction size
@@ -299,7 +299,7 @@ PTPMessageCommon *buildPTPMessage
#ifdef DEBUG
for (int n = 0; n < PTP_CLOCK_IDENTITY_LENGTH; ++n) { // MMM
- fprintf(stderr, "%c",
+ XPTPD_PRINTF("%c",
pdelay_resp_msg->
requestingPortIdentity.clockIdentity
[n]);
@@ -612,14 +612,14 @@ bool PTPMessageAnnounce::isBetterThan(PTPMessageAnnounce * msg)
msg->getGrandmasterIdentity((char *)that1 + 6);
#if 0
- fprintf(stderr, "Us: ");
+ XPTPD_PRINTF("Us: ");
for (int i = 0; i < 14; ++i)
- fprintf(stderr, "%hhx", this1[i]);
- fprintf(stderr, "\n");
- fprintf(stderr, "Them: ");
+ XPTPD_PRINTF("%hhx", this1[i]);
+ XPTPD_PRINTF("\n");
+ XPTPD_PRINTF("Them: ");
for (int i = 0; i < 14; ++i)
- fprintf(stderr, "%hhx", that1[i]);
- fprintf(stderr, "\n");
+ XPTPD_PRINTF("%hhx", that1[i]);
+ XPTPD_PRINTF("\n");
#endif
return (memcmp(this1, that1, 14) < 0) ? true : false;
@@ -873,9 +873,9 @@ void PTPMessageFollowUp::sendPort(IEEE1588Port * port,
XPTPD_INFO("Follow-up Dump:\n");
#ifdef DEBUG
for (int i = 0; i < messageLength; ++i) {
- fprintf(stderr, "%d:%02x ", i, (unsigned char)buf[i]);
+ XPTPD_PRINTF("%d:%02x ", i, (unsigned char)buf[i]);
}
- fprintf(stderr, "\n");
+ XPTPD_PRINTF("\n");
#endif
#endif
@@ -1068,9 +1068,9 @@ void PTPMessagePathDelayReq::processMessage(IEEE1588Port * port)
#ifdef DEBUG
for (int n = 0; n < PTP_CLOCK_IDENTITY_LENGTH; ++n) {
- fprintf(stderr, "%c", resp_id.clockIdentity[n]);
+ XPTPD_PRINTF("%c", resp_id.clockIdentity[n]);
}
- fprintf(stderr, "\"\n");
+ XPTPD_PRINTF("\"\n");
#endif
this->getPortIdentity(&requestingPortIdentity_p);
@@ -1203,7 +1203,7 @@ void PTPMessagePathDelayResp::processMessage(IEEE1588Port * port)
}
if (port->tryPDelayRxLock() != true) {
- fprintf(stderr, "Failed to get PDelay RX Lock\n");
+ XPTPD_PRINTF("Failed to get PDelay RX Lock\n");
return;
}