]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Update README.md
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Tue, 24 May 2022 09:00:22 +0000 (10:00 +0100)
committerGitHub <noreply@github.com>
Tue, 24 May 2022 09:00:22 +0000 (10:00 +0100)
README.md

index 144c81ad3cd7a94f034b1ae429c688a0abd115bd..ddc982534bd8d5af2418021873148f6f1b4688c3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,24 +3,6 @@
 
 It is a companion application to [Shairport Sync](https://github.com/mikebrady/shairport-sync) and provides timing information for AirPlay 2 operation.
 
-A _timing peer list_ can be sent to `nqptp` over port 9000. The list consists of the letter `T` followed by a space-separated list of the IP numbers of the timing peers. The list replaces any existing timing peer list.
-
-Information about the timing peer list's *master clock* is provided via a [POSIX shared memory](https://pubs.opengroup.org/onlinepubs/007908799/xsh/shm_open.html) interface. 
-
-
-Here are details of the interface:
-```c
-struct shm_structure {
-  pthread_mutex_t shm_mutex;            // for safely accessing the structure
-  uint16_t version;                     // check this is equal to NQPTP_SHM_STRUCTURES_VERSION
-  uint64_t master_clock_id;             // the current master clock
-  char master_clock_ip[64];             // where it's coming from
-  uint64_t local_time;                  // the time when the offset was calculated
-  uint64_t local_to_master_time_offset; // add this to the local time to get master clock time
-  uint64_t master_clock_start_time;     // this is when the master clock became master
-};
-```
-
 # Installation
 
 This guide is for recent Linux and FreeBSD systems.
@@ -120,7 +102,26 @@ Please note that `nqptp` must run in `root` mode to be able to access ports 319
 
 Since `nqptp` uses ports 319 and 320, it can not coexist with any other user of those ports, such as full PTP service daemons.
 
-Programmatically, if you wish to use the shared mutex to ensure records are not altered while you are accessing them, you should open your side of the shared memory interface with read-write permission. Be aware that while your program has the mutex lock, it is in a "critical region" where it can halt `nqptp`, so keep any activity while you have the lock very short and very simple, e.g. copying the contents of shared memory to local memory. 
+# Programming Notes
+A _timing peer list_ can be sent to `nqptp` over port 9000. The list consists of the letter `T` followed by a space-separated list of the IP numbers of the timing peers. The list replaces any existing timing peer list.
+
+Information about the timing peer list's *master clock* is provided via a [POSIX shared memory](https://pubs.opengroup.org/onlinepubs/007908799/xsh/shm_open.html) interface. 
+
+
+Here are details of the interface:
+```c
+struct shm_structure {
+  pthread_mutex_t shm_mutex;            // for safely accessing the structure
+  uint16_t version;                     // check this is equal to NQPTP_SHM_STRUCTURES_VERSION
+  uint64_t master_clock_id;             // the current master clock
+  char master_clock_ip[64];             // where it's coming from
+  uint64_t local_time;                  // the time when the offset was calculated
+  uint64_t local_to_master_time_offset; // add this to the local time to get master clock time
+  uint64_t master_clock_start_time;     // this is when the master clock became master
+};
+```
+
+If you wish to use the shared mutex to ensure records are not altered while you are accessing them, you should open your side of the shared memory interface with read-write permission. Be aware that while your program has the mutex lock, it is in a "critical region" where it can halt `nqptp`, so keep any activity while you have the lock very short and very simple, e.g. copying the contents of shared memory to local memory. 
 
 Clock records that are not updated for a period are deleted.