Skip to content

Commit 3a9a3c6

Browse files
committed
gc_config: fixed calling data latch to properly show PTP status
1 parent a92cde7 commit 3a9a3c6

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

tools/gc_config.cc

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,28 @@ int main(int argc, char *argv[])
101101
if (dev != 0)
102102
{
103103
bool showsummary=false;
104+
bool readonly=false;
104105
bool iponly=false;
105106

106107
// open device with control or read only access, depending on the
107108
// given parameters
108109

109110
if (i == argc || (i+1 == argc && std::string(argv[i]) == "--iponly"))
110111
{
111-
dev->open(rcg::Device::READONLY);
112+
try
113+
{
114+
// try to open with control to also show PTP status, which
115+
// requires calling data latch
116+
dev->open(rcg::Device::CONTROL);
117+
}
118+
catch (const std::exception &)
119+
{
120+
// fallback if another application is blocking the device, which
121+
// means that PTP status cannot be shown
122+
dev->open(rcg::Device::READONLY);
123+
readonly=true;
124+
}
125+
112126
showsummary=true;
113127
}
114128
else
@@ -249,11 +263,21 @@ int main(int argc, char *argv[])
249263
// just test if Ptp parameters are available
250264
rcg::getString(nodemap, "PtpEnable", true);
251265

252-
std::cout << "PTP: " << rcg::getString(nodemap, "PtpEnable") << std::endl;
253-
std::cout << "PTP status: " << rcg::getString(nodemap, "PtpStatus") << std::endl;
254-
std::cout << "PTP offset: " << rcg::getInteger(nodemap, "PtpOffsetFromMaster") << " ns" << std::endl;
266+
if (!readonly)
267+
{
268+
rcg::callCommand(nodemap, "PtpDataSetLatch");
269+
270+
std::cout << "PTP: " << rcg::getString(nodemap, "PtpEnable") << std::endl;
271+
std::cout << "PTP status: " << rcg::getString(nodemap, "PtpStatus") << std::endl;
272+
std::cout << "PTP offset: " << rcg::getInteger(nodemap, "PtpOffsetFromMaster") << " ns" << std::endl;
273+
}
274+
else
275+
{
276+
std::cout << "Ptp cannot be shown due to another application with control access." << std::endl;
277+
std::cout << std::endl;
278+
}
255279
}
256-
catch (const std::exception &)
280+
catch (const std::exception &ex)
257281
{
258282
std::cout << "Ptp parameters are not available" << std::endl;
259283
std::cout << std::endl;

0 commit comments

Comments
 (0)