flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
profiles.c
Go to the documentation of this file.
1#include "profiles.h"
2
3#include "ptp_types.h"
5#include <stdint.h>
6#include <string.h>
7
8char *PTP_TRANSPEC_HINT[] = { "unknown (default) [0]", "gPTP (802.1AS) [1]" };
9char *PTP_TRANSPORT_TYPE_HINT[] = { "IPv4", "802.3" };
10char *PTP_DELMECH_HINT[] = { "E2E", "P2P" };
11char *PTP_FLAGS_HINT[] = { "Sync (and Follow_Up) messages will only be issued if the peer slave proves compliant", "This node is SLAVE-ONLY" };
12
14 MSG(PTP_COLOR_BGREEN "---- PTP PROFILE ----\n"
15 PTP_COLOR_BYELLOW " transport specific: " PTP_COLOR_CYAN "%s\n"
16 PTP_COLOR_BYELLOW " transport: " PTP_COLOR_CYAN"%s\n"
17 PTP_COLOR_BYELLOW " delay mechanism: " PTP_COLOR_CYAN"%s\n"
18 PTP_COLOR_BYELLOW " domain: " PTP_COLOR_CYAN "%u\n",
23
24 int8_t drlp = ptp_get_delay_req_log_period();
25 if (drlp != PTP_LOGPER_SYNCMATCHED) {
26 MSG(PTP_COLOR_BYELLOW " logDelayReqPeriod: " PTP_COLOR_CYAN "%d\n", drlp);
27 } else {
28 MSG(PTP_COLOR_BYELLOW " logDelayReqPeriod: " PTP_COLOR_CYAN "SYNC MATCHED\n");
29 }
30
31 MSG(PTP_COLOR_BYELLOW " logSyncPeriod: " PTP_COLOR_CYAN "%d\n", ptp_get_sync_log_period());
32 MSG(PTP_COLOR_BYELLOW " logAnnouncePeriod: " PTP_COLOR_CYAN "%d\n", ptp_get_announce_log_period());
33
34 const char * tlvSet = ptp_get_loaded_tlv_chain();
35 if (!strcmp(tlvSet, "")) {
36 tlvSet = "none";
37 }
38 MSG(PTP_COLOR_BYELLOW " TLV-chain: " PTP_COLOR_CYAN "%s\n", tlvSet);
39
40 uint8_t flags = ptp_get_profile_flags();
41 MSG(PTP_COLOR_BYELLOW " flags: " PTP_COLOR_CYAN "0x%X\n", flags);
42 for (uint8_t i = 0; i < PTP_PF_N - 1; i++) {
43 uint8_t mask = 1 << i;
44 bool on = (flags & mask) != 0;
45 const char * color = on ? (PTP_COLOR_BGREEN) : (PTP_COLOR_BRED);
46 char bullet = on ? '+' : '-';
47 MSG(" %s%c (0x%X) %s" PTP_COLOR_RESET "\n", color, bullet, mask, PTP_FLAGS_HINT[i]);
48 }
49}
void ptp_print_profile()
Definition: profiles.c:13
char * PTP_TRANSPORT_TYPE_HINT[]
Hint on transport types.
Definition: profiles.c:9
char * PTP_FLAGS_HINT[]
Hints for.
Definition: profiles.c:11
char * PTP_TRANSPEC_HINT[]
Hint on transport specific field.
Definition: profiles.c:8
char * PTP_DELMECH_HINT[]
Hint on delay mechanism.
Definition: profiles.c:10
This module implements defines a single method that prints a verbose summary of the operating PTP pro...
#define PTP_COLOR_BYELLOW
Bright yellow.
Definition: ptp_defs.h:150
#define PTP_COLOR_BGREEN
Bright green.
Definition: ptp_defs.h:148
#define PTP_COLOR_CYAN
Cyan.
Definition: ptp_defs.h:154
#define PTP_COLOR_BRED
Bright red.
Definition: ptp_defs.h:146
#define PTP_COLOR_RESET
Reset colors.
Definition: ptp_defs.h:155
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
@ PTP_LOGPER_SYNCMATCHED
Messaging occurs whenever a Sync arrives.
Definition: ptp_types.h:281
@ PTP_PF_N
Number of available PTP profile flags.
Definition: ptp_types.h:325
PtpDelayMechanism ptp_get_delay_mechanism()
int8_t ptp_get_announce_log_period()
PtpTransportType ptp_get_transport_type()
uint8_t ptp_get_profile_flags()
int8_t ptp_get_sync_log_period()
int8_t ptp_get_delay_req_log_period()
uint8_t ptp_get_domain()
PtpTransportSpecific ptp_get_transport_specific()
const char * ptp_get_loaded_tlv_chain()
This module features functions to tweak around the PTP engine's almost every property.