Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
7e2f1211
Commit
7e2f1211
authored
Nov 06, 2017
by
Andreas Schmidt
Browse files
Add hardware timestamping bindings to Python.
parent
a6ba8861
Changes
2
Hide whitespace changes
Inline
Side-by-side
prrt/cprrt.pxd
View file @
7e2f1211
...
...
@@ -121,6 +121,8 @@ cdef extern from "proto/socket.h":
cdef
PrrtSocket
*
PrrtSocket_create
(
const
uint32_t
maximum_payload_size
,
const
uint32_t
target_delay
)
int
PrrtSocket_bind
(
PrrtSocket
*
sock_ptr
,
const_char
*
ipAddress
,
const
uint16_t
port
)
bint
PrrtSocket_enable_hardware_timestamping
(
PrrtSocket
*
s
,
const_char
*
interface_name
)
int
PrrtSocket_close
(
const
PrrtSocket
*
sock_ptr
)
int
PrrtSocket_connect
(
PrrtSocket
*
sock_ptr
,
const_char
*
host
,
const
uint16_t
port
)
int
PrrtSocket_send_sync
(
PrrtSocket
*
sock_ptr
,
const
uint8_t
*
data
,
const
size_t
data_len
)
...
...
@@ -186,4 +188,3 @@ cdef extern from "util/pipe.h":
cdef
extern
from
"util/mpsc_queue.h"
:
ctypedef
struct
MPSCQueue
:
pass
prrt/prrt.pyx
View file @
7e2f1211
...
...
@@ -173,12 +173,14 @@ cdef class PrrtSocket:
cdef
cprrt
.
PrrtSocket
*
_c_socket
_epoch
=
datetime
.
datetime
.
utcfromtimestamp
(
0
)
def
__cinit__
(
self
,
address
,
maximum_payload_size
=
1400
,
target_delay
=
1
,
thread_pinning
=
False
):
def
__cinit__
(
self
,
address
,
maximum_payload_size
=
1400
,
target_delay
=
1
,
thread_pinning
=
False
,
hardware_timestamping_interface
=
None
):
host
,
port
=
address
target_delay_us
=
target_delay
*
1000
**
2
self
.
_c_socket
=
cprrt
.
PrrtSocket_create
(
maximum_payload_size
,
target_delay_us
)
if
thread_pinning
:
cprrt
.
PrrtSocket_enable_thread_pinning
(
self
.
_c_socket
)
if
hardware_timestamping_interface
is
not
None
:
cprrt
.
PrrtSocket_enable_hardware_timestamping
(
self
.
_c_socket
,
hardware_timestamping_interface
.
encode
(
"UTF-8"
))
h_errno
=
cprrt
.
PrrtSocket_bind
(
self
.
_c_socket
,
host
.
encode
(
"utf8"
),
port
)
if
h_errno
!=
0
:
# PrrtSocket_bind calls PrrtSocket_close on error
...
...
Write
Preview
Supports
Markdown
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