From 6c11d615cb9ffa6e4ed3c7faf25746dc53ddf634 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 09:43:02 -0500 Subject: gPTP: move debugout macros from common dir to OS dir. No functional change. Issue #321 --- daemons/gptp/common/debugout.hpp | 48 ----------------------------- daemons/gptp/linux/src/debugout.hpp | 48 +++++++++++++++++++++++++++++ daemons/gptp/windows/daemon_cl/debugout.hpp | 48 +++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 48 deletions(-) delete mode 100644 daemons/gptp/common/debugout.hpp create mode 100644 daemons/gptp/linux/src/debugout.hpp create mode 100644 daemons/gptp/windows/daemon_cl/debugout.hpp diff --git a/daemons/gptp/common/debugout.hpp b/daemons/gptp/common/debugout.hpp deleted file mode 100644 index acb6d70e..00000000 --- a/daemons/gptp/common/debugout.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - - Copyright (c) 2009-2012, Intel Corporation - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of the Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -******************************************************************************/ - -#ifndef DEBUGOUT_HPP -#define DEBUGOUT_HPP - -/**@file*/ - -#include - -#define XPTPD_ERROR(fmt,...) fprintf( stderr, "ERROR at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints errors at stderr output*/ -#ifdef PTP_DEBUG -#define XPTPD_INFO(fmt,...) fprintf( stderr, "DEBUG at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints debugs at stderr output */ -#else -#define XPTPD_INFO(fmt,...) /*!< debugs disabled*/ -#endif - -#endif/*DEBUGOUT_HPP*/ diff --git a/daemons/gptp/linux/src/debugout.hpp b/daemons/gptp/linux/src/debugout.hpp new file mode 100644 index 00000000..ddccde2a --- /dev/null +++ b/daemons/gptp/linux/src/debugout.hpp @@ -0,0 +1,48 @@ +/****************************************************************************** + + Copyright (c) 2009-2012, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ + +#ifndef DEBUGOUT_HPP +#define DEBUGOUT_HPP + +/**@file*/ + +#include + +#define XPTPD_ERROR(fmt,...) fprintf( stderr, "ERROR at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints errors at stderr output*/ +#ifdef PTP_DEBUG +#define XPTPD_INFO(fmt,...) fprintf( stderr, "DEBUG at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints debugs at stderr output */ +#else +#define XPTPD_INFO(fmt,...) /*!< debugs disabled*/ +#endif + +#endif/*DEBUGOUT_HPP*/ diff --git a/daemons/gptp/windows/daemon_cl/debugout.hpp b/daemons/gptp/windows/daemon_cl/debugout.hpp new file mode 100644 index 00000000..ddccde2a --- /dev/null +++ b/daemons/gptp/windows/daemon_cl/debugout.hpp @@ -0,0 +1,48 @@ +/****************************************************************************** + + Copyright (c) 2009-2012, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ + +#ifndef DEBUGOUT_HPP +#define DEBUGOUT_HPP + +/**@file*/ + +#include + +#define XPTPD_ERROR(fmt,...) fprintf( stderr, "ERROR at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints errors at stderr output*/ +#ifdef PTP_DEBUG +#define XPTPD_INFO(fmt,...) fprintf( stderr, "DEBUG at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints debugs at stderr output */ +#else +#define XPTPD_INFO(fmt,...) /*!< debugs disabled*/ +#endif + +#endif/*DEBUGOUT_HPP*/ -- cgit v1.2.1 From 50cd6e0d613aa212212eeaa570a71ae6bc247dbd Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 10:01:17 -0500 Subject: gPTP: add XPTPD_PRINTF() macro to debugout.hpp. Issue #321 End goal here is to remove all printf() and fprintf() calls from gPTP source. --- daemons/gptp/linux/src/debugout.hpp | 1 + daemons/gptp/windows/daemon_cl/debugout.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/daemons/gptp/linux/src/debugout.hpp b/daemons/gptp/linux/src/debugout.hpp index ddccde2a..309235a1 100644 --- a/daemons/gptp/linux/src/debugout.hpp +++ b/daemons/gptp/linux/src/debugout.hpp @@ -39,6 +39,7 @@ #include #define XPTPD_ERROR(fmt,...) fprintf( stderr, "ERROR at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints errors at stderr output*/ +#define XPTPD_PRINTF(fmt,...) fprintf( stderr, fmt ,## __VA_ARGS__) /*!< Prints printf() status information at stderr output*/ #ifdef PTP_DEBUG #define XPTPD_INFO(fmt,...) fprintf( stderr, "DEBUG at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints debugs at stderr output */ #else diff --git a/daemons/gptp/windows/daemon_cl/debugout.hpp b/daemons/gptp/windows/daemon_cl/debugout.hpp index ddccde2a..309235a1 100644 --- a/daemons/gptp/windows/daemon_cl/debugout.hpp +++ b/daemons/gptp/windows/daemon_cl/debugout.hpp @@ -39,6 +39,7 @@ #include #define XPTPD_ERROR(fmt,...) fprintf( stderr, "ERROR at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints errors at stderr output*/ +#define XPTPD_PRINTF(fmt,...) fprintf( stderr, fmt ,## __VA_ARGS__) /*!< Prints printf() status information at stderr output*/ #ifdef PTP_DEBUG #define XPTPD_INFO(fmt,...) fprintf( stderr, "DEBUG at %u in %s: " fmt "\n", __LINE__, __FILE__ ,## __VA_ARGS__) /*!< Prints debugs at stderr output */ #else -- cgit v1.2.1 From 275c51f883de235124012ef62b9689938cf93482 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 10:25:33 -0500 Subject: gPTP: common: replace all fprintf() calls with XPTPD_PRINTF() macro. Issue #321 --- daemons/gptp/common/avbts_clock.hpp | 2 +- daemons/gptp/common/avbts_port.hpp | 2 +- daemons/gptp/common/ieee1588clock.cpp | 12 +++++------ daemons/gptp/common/ieee1588port.cpp | 21 +++++++++---------- daemons/gptp/common/ptp_message.cpp | 38 +++++++++++++++++------------------ 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; } -- cgit v1.2.1 From 9d8d95cf8a1ac34eebc3ad3e5effc8d42c6ad445 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 11:56:36 -0500 Subject: gPTP: correct Microsoft Visual Studio build. Issue #325. --- daemons/gptp/common/avbts_port.hpp | 2 +- daemons/gptp/common/gptp_cfg.cpp | 6 ++++++ daemons/gptp/common/ipcdef.hpp | 3 +++ daemons/gptp/windows/daemon_cl/daemon_cl.cpp | 14 +++++++++++++- daemons/gptp/windows/daemon_cl/windows_hal.hpp | 3 ++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/daemons/gptp/common/avbts_port.hpp b/daemons/gptp/common/avbts_port.hpp index 43defc2f..6867d60b 100644 --- a/daemons/gptp/common/avbts_port.hpp +++ b/daemons/gptp/common/avbts_port.hpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include diff --git a/daemons/gptp/common/gptp_cfg.cpp b/daemons/gptp/common/gptp_cfg.cpp index 73ed0f4f..dc0feea4 100644 --- a/daemons/gptp/common/gptp_cfg.cpp +++ b/daemons/gptp/common/gptp_cfg.cpp @@ -36,7 +36,13 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175. #include +/* need Microsoft version for strcasecmp() from GCC strings.h */ +#ifdef _MSC_VER +#define strcasecmp _stricmp +#else #include +#endif + #include #include diff --git a/daemons/gptp/common/ipcdef.hpp b/daemons/gptp/common/ipcdef.hpp index 9ffff86c..5acdd67e 100644 --- a/daemons/gptp/common/ipcdef.hpp +++ b/daemons/gptp/common/ipcdef.hpp @@ -49,6 +49,9 @@ #elif defined(_WIN32) || defined(_WIN64) +/*Definition of DWORD*/ +#include + /*Type for process ID*/ #define PID_TYPE DWORD diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.cpp b/daemons/gptp/windows/daemon_cl/daemon_cl.cpp index 83c2d79c..0f287b5b 100644 --- a/daemons/gptp/windows/daemon_cl/daemon_cl.cpp +++ b/daemons/gptp/windows/daemon_cl/daemon_cl.cpp @@ -42,6 +42,11 @@ POSSIBILITY OF SUCH DAMAGE. #define MACSTR_LENGTH 17 +#define PHY_DELAY_GB_TX_I20 184 //1G delay in nanoseconds +#define PHY_DELAY_GB_RX_I20 382 //1G delay in nanoseconds +#define PHY_DELAY_MB_TX_I20 1044 //100M delay in nanoseconds +#define PHY_DELAY_MB_RX_I20 2133 //100M delay in nanoseconds + static bool exit_flag; void print_usage( char *arg0 ) { @@ -82,6 +87,7 @@ int _tmain(int argc, _TCHAR* argv[]) int32_t offset = 0; bool syntonize = false; uint8_t priority1 = 248; + int phy_delays[4] = { 0 }; int i; // Register default network interface @@ -133,6 +139,12 @@ int _tmain(int argc, _TCHAR* argv[]) parseMacAddr( argv[i], local_addr_ostr ); LinkLayerAddress local_addr(local_addr_ostr); + // Initialize default PHY delays + phy_delays[0] = PHY_DELAY_GB_TX_I20; + phy_delays[1] = PHY_DELAY_GB_RX_I20; + phy_delays[2] = PHY_DELAY_MB_TX_I20; + phy_delays[3] = PHY_DELAY_MB_RX_I20; + // Create HWTimestamper object HWTimestamper *timestamper = new WindowsTimestamper(); // Create Clock object @@ -140,7 +152,7 @@ int _tmain(int argc, _TCHAR* argv[]) // Create Port Object linked to clock and low level IEEE1588Port *port = new IEEE1588Port( clock, 1, false, 0, timestamper, 0, &local_addr, condition_factory, thread_factory, timer_factory, lock_factory ); - if( !port->init_port() ) { + if (!port->init_port(phy_delays)) { printf( "Failed to initialize port\n" ); return -1; } diff --git a/daemons/gptp/windows/daemon_cl/windows_hal.hpp b/daemons/gptp/windows/daemon_cl/windows_hal.hpp index d251e18f..f1a9cebf 100644 --- a/daemons/gptp/windows/daemon_cl/windows_hal.hpp +++ b/daemons/gptp/windows/daemon_cl/windows_hal.hpp @@ -86,9 +86,10 @@ public: * @param addr [out] Remote link layer address * @param payload [out] Data buffer * @param length [out] Length of received data + * @param delay [in] Specifications for PHY input and output delays in nanoseconds * @return net_result structure */ - virtual net_result nrecv( LinkLayerAddress *addr, uint8_t *payload, size_t &length ) { + virtual net_result nrecv(LinkLayerAddress *addr, uint8_t *payload, size_t &length, struct phy_delay *delay) { packet_addr_t dest; packet_error_t pferror = recvFrame( handle, &dest, payload, length ); if( pferror != PACKET_NO_ERROR && pferror != PACKET_RECVTIMEOUT_ERROR ) return net_fatal; -- cgit v1.2.1 From 8e16843ee7600b641bee71eeaa5bdfa81ce747a8 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 11:57:57 -0500 Subject: gPTP: add CMAKE file. MSVC build tested so far. --- daemons/gptp/CMakeLists.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 daemons/gptp/CMakeLists.txt diff --git a/daemons/gptp/CMakeLists.txt b/daemons/gptp/CMakeLists.txt new file mode 100644 index 00000000..5be101f3 --- /dev/null +++ b/daemons/gptp/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required (VERSION 2.8) +project (gptp) + +include_directories( "./common" ) +file(GLOB GPTP_COMMON "./common/*.cpp" "./common/*.c") + +if(UNIX) + include_directories( include "./linux/src" ) + file(GLOB GPTP_OS "./linux/src/*.cpp") + target_link_libraries(gptp pthread) +elseif(WIN32) + if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + link_directories($ENV{WPCAP_DIR}/Lib/x64) + elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 ) + link_directories($ENV{WPCAP_DIR}/Lib) + endif() + + # HAVE_REMOTE change pcap include options + add_definitions(-D_CRT_SECURE_NO_WARNINGS -DHAVE_REMOTE) + include_directories( include "./windows/daemon_cl" $ENV{WPCAP_DIR}/Include ) + file(GLOB GPTP_OS "./windows/daemon_cl/*.cpp") + add_executable (gptp ${GPTP_COMMON} ${GPTP_OS}) + target_link_libraries(gptp wpcap Iphlpapi Ws2_32) +endif() + +#add_subdirectory("tests/simple") -- cgit v1.2.1 From 48621065b7228772774029599f7f3c60d5d14a08 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 12:49:18 -0500 Subject: gPTP: add named_pipe_test to Windows CMAKE config --- daemons/gptp/CMakeLists.txt | 4 +++- daemons/gptp/windows/named_pipe_test/CMakeLists.txt | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 daemons/gptp/windows/named_pipe_test/CMakeLists.txt diff --git a/daemons/gptp/CMakeLists.txt b/daemons/gptp/CMakeLists.txt index 5be101f3..1cb6d980 100644 --- a/daemons/gptp/CMakeLists.txt +++ b/daemons/gptp/CMakeLists.txt @@ -21,6 +21,8 @@ elseif(WIN32) file(GLOB GPTP_OS "./windows/daemon_cl/*.cpp") add_executable (gptp ${GPTP_COMMON} ${GPTP_OS}) target_link_libraries(gptp wpcap Iphlpapi Ws2_32) + + add_subdirectory("windows/named_pipe_test") + endif() -#add_subdirectory("tests/simple") diff --git a/daemons/gptp/windows/named_pipe_test/CMakeLists.txt b/daemons/gptp/windows/named_pipe_test/CMakeLists.txt new file mode 100644 index 00000000..82a9ddf9 --- /dev/null +++ b/daemons/gptp/windows/named_pipe_test/CMakeLists.txt @@ -0,0 +1,11 @@ +#Windows specifc build of named pipe test +cmake_minimum_required (VERSION 2.8) +project (named_pipe_test) + +include_directories( ".." ) +file(GLOB SRC "*.cpp") + +add_definitions(-D_CRT_SECURE_NO_WARNINGS ) +include_directories( include "../../common" ) +add_executable (named_pipe_test ${SRC}) +target_link_libraries(named_pipe_test Iphlpapi Ws2_32) -- cgit v1.2.1 From c886db382178579791cae3ce1d2a573b40c0a6ac Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Tue, 1 Dec 2015 12:56:55 -0500 Subject: gPTP: update Windows build requirements in README --- daemons/gptp/README.rst | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/daemons/gptp/README.rst b/daemons/gptp/README.rst index dcb19972..cba28067 100644 --- a/daemons/gptp/README.rst +++ b/daemons/gptp/README.rst @@ -65,19 +65,8 @@ Build Dependencies * WinPCAP Developer's Pack (WpdPack) is required for linking - downloadable from http://www.winpcap.org/devel.htm. -Extract WpdPack so the Include folder is in one of the below locations - -1- %ProgramData% - \WpdPack - \Include - \Lib - \Lib\x64 - -2- %USERPROFILE% - \src\pcap - \Include - \Lib - \Lib\x64 +The following environment variables must be defined: +* WPCAP_DIR the directory where WinPcap is installed * WinPCAP must also be installed on any machine where the daemon runs. -- cgit v1.2.1 From 61240f3d631d4d97032a4f908681c97e618a54d1 Mon Sep 17 00:00:00 2001 From: Andrew Elder Date: Fri, 11 Dec 2015 08:21:23 -0500 Subject: gPTP: windows build: remove MSVC project files, users should use CMAKE --- daemons/gptp/README.rst | 4 + daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj | 219 --------------------- .../windows/daemon_cl/daemon_cl.vcxproj.filters | 129 ------------ .../gptp/windows/daemon_cl/daemon_cl.vcxproj.user | 15 -- .../named_pipe_test/named_pipe_test.vcxproj | 162 --------------- .../named_pipe_test.vcxproj.filters | 36 ---- .../named_pipe_test/named_pipe_test.vcxproj.user | 3 - 7 files changed, 4 insertions(+), 564 deletions(-) delete mode 100644 daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj delete mode 100644 daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters delete mode 100644 daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.user delete mode 100644 daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj delete mode 100644 daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.filters delete mode 100644 daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.user diff --git a/daemons/gptp/README.rst b/daemons/gptp/README.rst index cba28067..1ef458c1 100644 --- a/daemons/gptp/README.rst +++ b/daemons/gptp/README.rst @@ -65,6 +65,10 @@ Build Dependencies * WinPCAP Developer's Pack (WpdPack) is required for linking - downloadable from http://www.winpcap.org/devel.htm. +* CMAKE 3.2.2 or later + +* Microsoft Visual Studio 2013 or later + The following environment variables must be defined: * WPCAP_DIR the directory where WinPcap is installed diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj deleted file mode 100644 index 4cb65d8d..00000000 --- a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj +++ /dev/null @@ -1,219 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {590D3055-A068-4B31-B4F9-B2ACC5F93663} - Win32Proj - daemon_cl - - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - false - true - Unicode - v120 - - - Application - false - true - Unicode - v120 - - - - - - - - - - - - - - - - - - - true - $(IncludePath) - - - true - $(ALLUSERSPROFILE)\WpdPack\Include;$(IncludePath) - - - false - $(IncludePath) - - - false - $(ALLUSERSPROFILE)\WpdPack\Include;$(IncludePath) - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;WPCAP;HAVE_REMOTE - $(ALLUSERSPROFILE)\WpdPack\Include;$(USERPROFILE)\src\pcap\Include;$(SolutionDir)\..\common;$(ProjectDir);%(AdditionalIncludeDirectories) - - - Console - true - wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) - $(ALLUSERSPROFILE)\WpdPack\Lib;$(USERPROFILE)\src\pcap\Lib;%(AdditionalLibraryDirectories) - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;WPCAP;HAVE_REMOTE - $(ALLUSERSPROFILE)\WpdPack\Include;$(USERPROFILE)\src\pcap\Include;$(SolutionDir)\..\common;$(ProjectDir);%(AdditionalIncludeDirectories) - - - Console - true - wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) - $(ALLUSERSPROFILE)\WpdPack\Lib\x64;$(USERPROFILE)\src\pcap\Lib\x64;%(AdditionalLibraryDirectories) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;WPCAP;HAVE_REMOTE - $(ALLUSERSPROFILE)\WpdPack\Include;$(USERPROFILE)\src\pcap\Include;$(SolutionDir)\..\common;$(ProjectDir);%(AdditionalIncludeDirectories) - - - Console - true - true - true - $(ALLUSERSPROFILE)\WpdPack\Lib;$(USERPROFILE)\src\pcap\Lib;%(AdditionalLibraryDirectories) - wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) - true - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;WPCAP;HAVE_REMOTE - $(ALLUSERSPROFILE)\WpdPack\Include;$(USERPROFILE)\src\pcap\Include;$(SolutionDir)\..\common;$(ProjectDir);%(AdditionalIncludeDirectories) - - - Console - true - true - true - $(ALLUSERSPROFILE)\WpdPack\Lib\x64;$(USERPROFILE)\src\pcap\Lib\x64;%(AdditionalLibraryDirectories) - wpcap.lib;Iphlpapi.lib;ws2_32.lib;%(AdditionalDependencies) - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NotUsing - - - NotUsing - - - NotUsing - - - NotUsing - - - NotUsing - NotUsing - - - - NotUsing - NotUsing - - - - Create - Create - Create - Create - - - - - - - diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters deleted file mode 100644 index b3c4f59a..00000000 --- a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.filters +++ /dev/null @@ -1,129 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - diff --git a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.user b/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.user deleted file mode 100644 index de099045..00000000 --- a/daemons/gptp/windows/daemon_cl/daemon_cl.vcxproj.user +++ /dev/null @@ -1,15 +0,0 @@ - - - - 88-88-88-88-87-88 - WindowsLocalDebugger - - - 00-13-20-F8-84-41 - WindowsLocalDebugger - - - /r 200 88-88-88-88-87-88 - WindowsLocalDebugger - - \ No newline at end of file diff --git a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj b/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj deleted file mode 100644 index 3043bdb7..00000000 --- a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {303FACBB-2A44-4511-A855-2B5B2C0E3A89} - Win32Proj - named_pipe_test - - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - false - true - Unicode - v120 - - - Application - false - true - Unicode - v120 - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - NotUsing - Level3 - Disabled - - - $(SolutionDir)\..\common;$(SolutionDir)\daemon_cl;%(AdditionalIncludeDirectories) - - - Console - true - - - - - Use - Level3 - Disabled - - - $(SolutionDir)\..\common;$(SolutionDir)\daemon_cl;%(AdditionalIncludeDirectories) - - - Console - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE - $(SolutionDir)\..\common;$(SolutionDir)\daemon_cl;%(AdditionalIncludeDirectories) - - - Console - true - true - true - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE - $(SolutionDir)\..\common;$(SolutionDir)\daemon_cl;%(AdditionalIncludeDirectories) - - - Console - true - true - true - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - \ No newline at end of file diff --git a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.filters b/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.filters deleted file mode 100644 index 6d9eabf2..00000000 --- a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.user b/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.user deleted file mode 100644 index ace9a86a..00000000 --- a/daemons/gptp/windows/named_pipe_test/named_pipe_test.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file -- cgit v1.2.1