Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
ce9576b4
Commit
ce9576b4
authored
Mar 17, 2021
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Choose GPIO to emit signal on in server
parent
2ed3e6df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
35 deletions
+13
-35
src/packet-exchange/src/server.c
src/packet-exchange/src/server.c
+13
-35
No files found.
src/packet-exchange/src/server.c
View file @
ce9576b4
...
@@ -42,7 +42,7 @@ typedef struct thread_param {
...
@@ -42,7 +42,7 @@ typedef struct thread_param {
int
affinity_cpu
;
int
affinity_cpu
;
uint64_t
latency_threshold
;
uint64_t
latency_threshold
;
int
emit_signal
;
int
emit_signal
_gpio
;
int
enable_diff_ts
;
int
enable_diff_ts
;
int
enable_receive_tracemark
;
int
enable_receive_tracemark
;
...
@@ -91,11 +91,8 @@ static uint64_t high_diff_ts = 0;
...
@@ -91,11 +91,8 @@ static uint64_t high_diff_ts = 0;
static
int
debug_latencies
=
0
;
static
int
debug_latencies
=
0
;
static
int
interval_us
;
static
int
interval_us
;
static
int
gpio86_fd
;
static
int
gpio_fd
;
static
int
gpio84_fd
;
static
int
gpio_state
;
static
int
gpio86_state
;
static
int
gpio84_state
;
static
int
received_reverse_motor
=
0
;
static
char
ts_tracemark_buf
[
64
];
static
char
ts_tracemark_buf
[
64
];
...
@@ -110,7 +107,7 @@ static void help(char *argv[]) {
...
@@ -110,7 +107,7 @@ static void help(char *argv[]) {
" -i USEC RT thread wake-up interval (default: 10ms)
\n
"
" -i USEC RT thread wake-up interval (default: 10ms)
\n
"
" -r USEC non-RT main thread refresh interval
\n
"
" -r USEC non-RT main thread refresh interval
\n
"
" -d BUF_LEN Set the length of tx buffer
\n
"
" -d BUF_LEN Set the length of tx buffer
\n
"
" -c
Receive timestamp and emit signal
\n
"
" -c
GPIO Receive timestamp and emit signal on given GPIO
\n
"
" -s NS Common start time reference
\n
"
" -s NS Common start time reference
\n
"
" -C Receive timestamp and print difference with current time
\n
"
" -C Receive timestamp and print difference with current time
\n
"
" -b CLIENT_IP Server side RTT
\n
"
" -b CLIENT_IP Server side RTT
\n
"
...
@@ -135,7 +132,6 @@ static void *emit_signal_thread(void *p) {
...
@@ -135,7 +132,6 @@ static void *emit_signal_thread(void *p) {
int64_t
emit_diff
,
ts_diff
;
int64_t
emit_diff
,
ts_diff
;
int
latency_spike
=
0
;
int
latency_spike
=
0
;
int
ret
;
int
ret
;
int
reverse_motor
=
0
;
// Set thread CPU affinity
// Set thread CPU affinity
if
(
thread_params
.
affinity_cpu
)
{
if
(
thread_params
.
affinity_cpu
)
{
...
@@ -151,27 +147,13 @@ static void *emit_signal_thread(void *p) {
...
@@ -151,27 +147,13 @@ static void *emit_signal_thread(void *p) {
for
(
int
i
=
0
;;
i
++
)
{
for
(
int
i
=
0
;;
i
++
)
{
pthread_cond_wait
(
&
emit_signal_ts_received
,
&
emit_signal_mutex
);
pthread_cond_wait
(
&
emit_signal_ts_received
,
&
emit_signal_mutex
);
if
(
received_reverse_motor
)
{
received_reverse_motor
=
0
;
reverse_motor
=
1
;
continue
;
}
ret
=
clock_nanosleep
(
CLOCK_REALTIME
,
TIMER_ABSTIME
,
&
emit_signal_next
,
NULL
);
ret
=
clock_nanosleep
(
CLOCK_REALTIME
,
TIMER_ABSTIME
,
&
emit_signal_next
,
NULL
);
if
(
ret
)
{
if
(
ret
)
{
fprintf
(
stderr
,
"clock_nanosleep returned error: %d, aborting...
\n
"
,
ret
);
fprintf
(
stderr
,
"clock_nanosleep returned error: %d, aborting...
\n
"
,
ret
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
reverse_motor
)
{
gpio_state
=
toggle_gpio
(
gpio_fd
,
gpio_state
);
gpio84_state
=
toggle_gpio
(
gpio84_fd
,
gpio84_state
);
reverse_motor
=
0
;
}
else
{
gpio86_state
=
toggle_gpio
(
gpio86_fd
,
gpio86_state
);
usleep
(
3
);
gpio86_state
=
toggle_gpio
(
gpio86_fd
,
gpio86_state
);
}
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
...
@@ -273,7 +255,7 @@ static void *tsn_thread(void *p) {
...
@@ -273,7 +255,7 @@ static void *tsn_thread(void *p) {
}
}
// Get signal timestamp
// Get signal timestamp
if
(
thread_params
.
emit_signal
)
{
if
(
thread_params
.
emit_signal
_gpio
)
{
uint64_t
emit_signal_t
;
uint64_t
emit_signal_t
;
if
(
tsn_task
==
XDP_TASK
)
if
(
tsn_task
==
XDP_TASK
)
...
@@ -281,14 +263,11 @@ static void *tsn_thread(void *p) {
...
@@ -281,14 +263,11 @@ static void *tsn_thread(void *p) {
else
else
emit_signal_t
=
decode
(
ingress_stats
.
data
);
emit_signal_t
=
decode
(
ingress_stats
.
data
);
if
(
emit_signal_t
<
UINT64_C
(
1576800000000000000
)
&&
emit_signal_t
!=
17
)
if
(
emit_signal_t
<
UINT64_C
(
1576800000000000000
))
continue
;
continue
;
pthread_mutex_lock
(
&
emit_signal_mutex
);
pthread_mutex_lock
(
&
emit_signal_mutex
);
if
(
emit_signal_t
==
17
)
emit_signal_next
=
uint_to_ts
(
emit_signal_t
);
received_reverse_motor
=
1
;
else
emit_signal_next
=
uint_to_ts
(
emit_signal_t
);
pthread_cond_signal
(
&
emit_signal_ts_received
);
pthread_cond_signal
(
&
emit_signal_ts_received
);
pthread_mutex_unlock
(
&
emit_signal_mutex
);
pthread_mutex_unlock
(
&
emit_signal_mutex
);
}
}
...
@@ -424,7 +403,7 @@ int main(int argc, char *argv[]) {
...
@@ -424,7 +403,7 @@ int main(int argc, char *argv[]) {
// Default configuration values
// Default configuration values
thread_params
.
interval
=
100000
*
1000
;
thread_params
.
interval
=
100000
*
1000
;
thread_params
.
priority
=
98
;
thread_params
.
priority
=
98
;
thread_params
.
emit_signal
=
0
;
thread_params
.
emit_signal
_gpio
=
0
;
thread_params
.
affinity_cpu
=
0
;
thread_params
.
affinity_cpu
=
0
;
thread_params
.
enable_diff_ts
=
0
;
thread_params
.
enable_diff_ts
=
0
;
thread_params
.
enable_receive_tracemark
=
0
;
thread_params
.
enable_receive_tracemark
=
0
;
...
@@ -473,12 +452,11 @@ int main(int argc, char *argv[]) {
...
@@ -473,12 +452,11 @@ int main(int argc, char *argv[]) {
if
(
tsn_task
==
RTT_TASK
)
if
(
tsn_task
==
RTT_TASK
)
init_udp_send
(
&
egress_info
,
0
,
0
);
init_udp_send
(
&
egress_info
,
0
,
0
);
if
(
thread_params
.
emit_signal
)
{
if
(
thread_params
.
emit_signal
_gpio
)
{
pthread_mutex_init
(
&
emit_signal_mutex
,
NULL
);
pthread_mutex_init
(
&
emit_signal_mutex
,
NULL
);
pthread_cond_init
(
&
emit_signal_ts_received
,
NULL
);
pthread_cond_init
(
&
emit_signal_ts_received
,
NULL
);
gpio86_state
=
enable_gpio
(
&
gpio86_fd
,
86
);
gpio_state
=
enable_gpio
(
&
gpio_fd
,
thread_params
.
emit_signal_gpio
);
gpio84_state
=
enable_gpio
(
&
gpio84_fd
,
84
);
}
}
create_thread
(
tsn_thread
);
create_thread
(
tsn_thread
);
...
@@ -610,7 +588,7 @@ static void process_options(int argc, char *argv[]) {
...
@@ -610,7 +588,7 @@ static void process_options(int argc, char *argv[]) {
int
network_if_specified
=
0
;
int
network_if_specified
=
0
;
for
(;;)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"a:b:cCs:d:f:ghi:p:r:tvxDXT:GMS"
);
int
c
=
getopt
(
argc
,
argv
,
"a:b:c
:
Cs:d:f:ghi:p:r:tvxDXT:GMS"
);
if
(
c
==
-
1
)
break
;
if
(
c
==
-
1
)
break
;
...
@@ -623,7 +601,7 @@ static void process_options(int argc, char *argv[]) {
...
@@ -623,7 +601,7 @@ static void process_options(int argc, char *argv[]) {
strcpy
(
egress_params
.
server_ip
,
optarg
);
strcpy
(
egress_params
.
server_ip
,
optarg
);
break
;
break
;
case
'c'
:
case
'c'
:
thread_params
.
emit_signal
=
1
;
thread_params
.
emit_signal
_gpio
=
atoi
(
optarg
)
;
break
;
break
;
case
'C'
:
case
'C'
:
thread_params
.
enable_diff_ts
=
1
;
thread_params
.
enable_diff_ts
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment