Commit 7e2f1211 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Add hardware timestamping bindings to Python.

parent a6ba8861
......@@ -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:
......@@ -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:
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment