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
a42fb197
Commit
a42fb197
authored
Jan 08, 2018
by
Andreas Schmidt
Browse files
Add Python bindings for all receive calls.
parent
ddfe37d0
Pipeline
#1808
failed with stages
in 1 minute and 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
prrt/prrt.pyx
View file @
a42fb197
from
libc.stdint
cimport
uint32_t
,
uint16_t
,
uint8_t
,
int32_t
from
libc.stdlib
cimport
malloc
,
free
from
posix.time
cimport
timespec
cimport
cprrt
...
...
@@ -189,6 +190,36 @@ cdef class PrrtSocket:
len
=
cprrt
.
PrrtSocket_recv
(
self
.
_c_socket
,
<
void
*>
buffer
)
return
buffer
[:
len
]
def
receive_asap
(
self
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
with
nogil
:
len
=
cprrt
.
PrrtSocket_receive_asap
(
self
.
_c_socket
,
<
void
*>
buffer
)
return
buffer
[:
len
]
def
receive_asap_wait
(
self
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
with
nogil
:
len
=
cprrt
.
PrrtSocket_receive_asap_wait
(
self
.
_c_socket
,
<
void
*>
buffer
)
return
buffer
[:
len
]
def
receive_asap_timedwait
(
self
,
deadline
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
cdef
timespec
deadline_timespec
=
timespec
(
deadline
.
seconds
,
deadline
.
microseconds
*
1000
)
with
nogil
:
len
=
cprrt
.
PrrtSocket_receive_asap_timedwait
(
self
.
_c_socket
,
<
void
*>
buffer
,
&
deadline_timespec
)
return
buffer
[:
len
]
def
receive_ordered
(
self
,
time_window
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
cdef
uint32_t
time_window_us
=
time_window
*
(
1000
**
2
)
with
nogil
:
len
=
cprrt
.
PrrtSocket_receive_ordered
(
self
.
_c_socket
,
<
void
*>
buffer
,
time_window_us
)
return
buffer
[:
len
]
def
receive_ordered_wait
(
self
,
time_window
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
...
...
@@ -197,6 +228,15 @@ cdef class PrrtSocket:
len
=
cprrt
.
PrrtSocket_receive_ordered_wait
(
self
.
_c_socket
,
<
void
*>
buffer
,
time_window_us
)
return
buffer
[:
len
]
def
receive_ordered_timedwait
(
self
,
time_window
,
deadline
):
cdef
char
buffer
[
65536
]
cdef
int32_t
len
cdef
uint32_t
time_window_us
=
time_window
*
(
1000
**
2
)
cdef
timespec
deadline_timespec
=
timespec
(
deadline
.
seconds
,
deadline
.
microseconds
*
1000
)
with
nogil
:
len
=
cprrt
.
PrrtSocket_receive_ordered_timedwait
(
self
.
_c_socket
,
<
void
*>
buffer
,
time_window_us
,
&
deadline_timespec
)
return
buffer
[:
len
]
def
connect
(
self
,
host
,
port
):
cdef
bytes
encodedHost
=
host
.
encode
(
"utf-8"
)
cprrt
.
PrrtSocket_connect
(
self
.
_c_socket
,
encodedHost
,
port
)
...
...
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