0

I'm doing a small project with two Raspberry Pi's. I want to sync their clocks using Precision Time Protocol (one as master clock and another as slave clock).

Now I'm interested in logging the data you see when using the -V command. I'm doing the following atm:

For RPi 1:

sudo ptpd --interface wlan0 -M -L

For RPi 2:

sudo ptpd --interface wlan0 -s -L -V > onewaydelay.csv

The output is the typical

#Timestamp, State, Clock ID, One Way Delay, Offset From Master, Slave to Master, Master to Slave, Observed Drift, Last Packet Received.

The thing is I'm only interested in logging the Timestamp and One Way Delay so that I can plot the One Way Delay and see how it changes over time. So my question is:

  • Is it possible to edit the output (using the -V command) so that it only prints Timestamp and One Way Delay?

Using the -V command the output looks (one line - comma separated):

2017-10-12 14:41:48.763883, slv, b827ebfffe9adfc7(unknown)/01, 0.045879356, -0.145651366, 0.319974024, -0.108966784, -500000.000000000, S 
  • Using the -V command the output looks (one line - comma separated): 2017-10-12 14:41:48.763883, slv, b827ebfffe9adfc7(unknown)/01, 0.045879356, -0.145651366, 0.319974024, -0.108966784, -500000.000000000, S – user75374 Nov 10 '17 at 14:19
  • 1) I put back your comment in original question to make it more readable. 2) I edit title, this is hardly a precision time problem, but rather a filtering one. – Archemar Nov 10 '17 at 14:55
0

Are you not able to pipe to awk? e.g

sudo ptpd --interface wlan0 -s -L -V | awk /Timestamp,OneWayDel/ > onewaydelay.csv
  • I can't get that to work. I even tried only doing all the following variations: ... | awk /Timestamp,OneWayDel/ > onewaydelay.csv ... | awk /Timestamp,OneWayDelay/ > onewaydelay.csv ... | awk /Timestamp/ > onewaydelay.csv ... | awk '/Timestamp/' > onewaydelay.csv ... | awk /One Way Delay/ > onewaydelay.csv ... | awk '/One Way Delay/' > onewaydelay.csv In every case the .csv file contains no data at all. – user75374 Nov 10 '17 at 12:13
0

what your are looking for is

| awk -F, '{printf "%s,%s\n",$1,$4;}'

where

  • -F, tell awk to separate field on comma

  • printf "%s,%s\n",$1,$4; print 1st and 4th field separated by , (you can use ; if you like)

to have only HMS

| awk -F, '{printf "%s,%s\n",substr($1,10,8),$4;}'

using substr(string,from,length)'s awk function.

  • It works. Is it possible to exclude the date from the Timestamp so it only shows hour:minute:second? – user75374 Nov 13 '17 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.