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
Robotlab
firefly
Commits
fdd9817f
Commit
fdd9817f
authored
Dec 19, 2014
by
Tommy Olofsson
Browse files
WIP: Getting it working with current labcomm.
parent
caf1be06
Changes
14
Hide whitespace changes
Inline
Side-by-side
cmake_modules/FindLabComm.cmake
View file @
fdd9817f
...
...
@@ -19,9 +19,9 @@ endif()
set
(
HEADER_NAMES labcomm.h labcomm_private.h
)
# Libraries to find
set
(
LABCOMM_NAME labcomm
)
set
(
LABCOMM_NAME labcomm
2014
)
find_path
(
LABCOMM_INCLUDE_DIR NAMES
${
HEADER_NAMES
}
PATHS
${
LABCOMM_ROOT_DIR
}
)
find_path
(
LABCOMM_INCLUDE_DIR NAMES
${
HEADER_NAMES
}
PATHS
${
LABCOMM_ROOT_DIR
}
/2014
)
find_library
(
LABCOMM_LIBRARY NAMES
${
LABCOMM_NAME
}
PATHS
${
LABCOMM_ROOT_DIR
}
)
set
(
LABCOMM_PROCESS_INCLUDES LABCOMM_INCLUDE_DIR
)
...
...
include/protocol/firefly_protocol.h
View file @
fdd9817f
...
...
@@ -345,23 +345,23 @@ void firefly_channel_unrestrict(struct firefly_channel *chan);
/* Stuff for predictable type registration. */
typedef
void
(
*
labcomm_handler_function
)(
void
*
value
,
void
*
context
);
typedef
void
(
*
firefly_
labcomm_handler_function
)(
void
*
value
,
void
*
context
);
typedef
int
(
*
labcomm_decoder_register_function
)(
struct
labcomm_decoder
*
d
,
labcomm_handler_function
f
,
typedef
int
(
*
firefly_
labcomm_decoder_register_function
)(
struct
labcomm_decoder
*
d
,
firefly_
labcomm_handler_function
f
,
void
*
context
);
typedef
int
(
*
labcomm_encoder_register_function
)(
struct
labcomm_encoder
*
e
);
typedef
int
(
*
firefly_
labcomm_encoder_register_function
)(
struct
labcomm_encoder
*
e
);
struct
firefly_channel_decoder_type
{
labcomm_decoder_register_function
register_func
;
labcomm_handler_function
handler
;
firefly_
labcomm_decoder_register_function
register_func
;
firefly_
labcomm_handler_function
handler
;
void
*
context
;
struct
firefly_channel_decoder_type
*
next
;
};
struct
firefly_channel_encoder_type
{
labcomm_encoder_register_function
register_func
;
firefly_
labcomm_encoder_register_function
register_func
;
struct
firefly_channel_encoder_type
*
next
;
};
...
...
@@ -380,13 +380,13 @@ void firefly_channel_types_free(struct firefly_channel_types *ct);
void
firefly_channel_types_add_decoder_type
(
struct
firefly_channel_types
*
types
,
labcomm_decoder_register_function
register_func
,
labcomm_handler_function
handler
,
firefly_
labcomm_decoder_register_function
register_func
,
firefly_
labcomm_handler_function
handler
,
void
*
context
);
void
firefly_channel_types_add_encoder_type
(
struct
firefly_channel_types
*
types
,
labcomm_encoder_register_function
register_func
);
firefly_
labcomm_encoder_register_function
register_func
);
/**
* Used to open with automatic restriction after type registration.
...
...
src/CMakeLists.txt
View file @
fdd9817f
...
...
@@ -32,7 +32,7 @@ set(DOC_GEN_API_DIR ${DOC_GEN_DIR}/api)
Set
(
DOC_GEN_FULL_DIR
${
DOC_GEN_DIR
}
/full
)
# Labcomm compiler:
set
(
LABCOMMC
${
Firefly_PROJECT_DIR
}
/tools/lab
C
omm.jar
)
set
(
LABCOMMC
${
Firefly_PROJECT_DIR
}
/tools/lab
c
omm
_2014_compiler
.jar
)
# Tell CMake to output library and executables directly in the build
# directory:
...
...
@@ -60,7 +60,7 @@ link_directories(${LINK_DIRECTORIES} ${LABCOMM_LIBRARIES})
## FLAGS {{{
set
(
C_STD
"-std=c99"
)
set
(
ERR_FLAGS
"-Wall -Wextra"
)
set
(
ERR_FLAGS
"-Wall -Wextra
-Wno-missing-field-initializers
"
)
if
(
DEFINED $ENV{DEBUG}
)
set
(
MACROS_DEF
"-DDEBUG -O0"
)
...
...
src/protocol/firefly_protocol.c
View file @
fdd9817f
...
...
@@ -23,73 +23,6 @@
*/
#define FIREFLY_PROTO_ACK_RESTRICT_ACK -1
/*
* Used by reg_proto_sigs() below to "short circuit" the connection during
* the initial registration of protocol types.
*/
static
void
signature_trans_write
(
unsigned
char
*
data
,
size_t
size
,
struct
firefly_connection
*
conn
,
bool
important
,
unsigned
char
*
id
)
{
UNUSED_VAR
(
important
);
UNUSED_VAR
(
id
);
unsigned
char
*
cpy_data
=
FIREFLY_RUNTIME_MALLOC
(
conn
,
size
);
memcpy
(
cpy_data
,
data
,
size
);
protocol_data_received
(
conn
,
cpy_data
,
size
);
}
static
struct
firefly_transport_connection
sig_transport
=
{
.
write
=
signature_trans_write
,
.
ack
=
NULL
,
.
open
=
NULL
,
.
close
=
NULL
};
void
reg_proto_sigs
(
struct
labcomm_encoder
*
enc
,
struct
labcomm_decoder
*
dec
,
struct
firefly_connection
*
conn
)
{
struct
firefly_transport_connection
*
orig_transport
;
orig_transport
=
conn
->
transport
;
conn
->
transport
=
&
sig_transport
;
init_firefly_protocol__signatures
();
labcomm_decoder_register_firefly_protocol_data_sample
(
dec
,
handle_data_sample
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_request
(
dec
,
handle_channel_request
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_response
(
dec
,
handle_channel_response
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_ack
(
dec
,
handle_channel_ack
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_close
(
dec
,
handle_channel_close
,
conn
);
labcomm_decoder_register_firefly_protocol_ack
(
dec
,
handle_ack
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_restrict_request
(
dec
,
handle_channel_restrict_request
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_restrict_ack
(
dec
,
handle_channel_restrict_ack
,
conn
);
labcomm_encoder_register_firefly_protocol_data_sample
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_request
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_response
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_ack
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_close
(
enc
);
labcomm_encoder_register_firefly_protocol_ack
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_restrict_request
(
enc
);
labcomm_encoder_register_firefly_protocol_channel_restrict_ack
(
enc
);
conn
->
transport
=
orig_transport
;
}
static
void
firefly_unknown_dest
(
struct
firefly_connection
*
conn
,
int
src_id
,
int
dest_id
,
const
char
*
action
)
...
...
@@ -905,8 +838,8 @@ void firefly_channel_types_free(struct firefly_channel_types *ct)
void
firefly_channel_types_add_decoder_type
(
struct
firefly_channel_types
*
types
,
labcomm_decoder_register_function
register_func
,
labcomm_handler_function
handler
,
firefly_
labcomm_decoder_register_function
register_func
,
firefly_
labcomm_handler_function
handler
,
void
*
context
)
{
struct
firefly_channel_decoder_type
*
dt
;
...
...
@@ -924,7 +857,7 @@ void firefly_channel_types_add_decoder_type(
void
firefly_channel_types_add_encoder_type
(
struct
firefly_channel_types
*
types
,
labcomm_encoder_register_function
register_func
)
firefly_
labcomm_encoder_register_function
register_func
)
{
struct
firefly_channel_encoder_type
*
et
;
...
...
src/protocol/firefly_protocol_channel.c
View file @
fdd9817f
...
...
@@ -14,14 +14,31 @@ struct firefly_channel *firefly_channel_new(struct firefly_connection *conn)
struct
labcomm_writer
*
writer
;
chan
=
FIREFLY_MALLOC
(
sizeof
(
*
chan
));
if
(
!
chan
)
{
FFL
(
FIREFLY_ERROR_ALLOC
);
return
NULL
;
}
chan
->
conn
=
conn
;
chan
->
local_id
=
next_channel_id
(
conn
);
chan
->
remote_id
=
CHANNEL_ID_NOT_SET
;
chan
->
state
=
FIREFLY_CHANNEL_READY
;
chan
->
important_queue
=
NULL
;
chan
->
important_id
=
0
;
chan
->
current_seqno
=
0
;
chan
->
remote_seqno
=
0
;
chan
->
restricted_local
=
false
;
chan
->
restricted_remote
=
false
;
chan
->
auto_restrict
=
false
;
chan
->
enc_types
=
NULL
;
chan
->
seen_decoder_ids
=
NULL
;
chan
->
n_decoder_types
=
0
;
reader
=
protocol_labcomm_reader_new
(
conn
,
conn
->
lc_memory
);
writer
=
protocol_labcomm_writer_new
(
chan
,
conn
->
lc_memory
);
if
(
!
chan
||
!
reader
||
!
writer
)
{
if
(
!
reader
||
!
writer
)
{
FFL
(
FIREFLY_ERROR_ALLOC
);
protocol_labcomm_reader_free
(
reader
);
protocol_labcomm_writer_free
(
writer
);
FIREFLY_FREE
(
chan
);
return
NULL
;
}
proto_decoder
=
labcomm_decoder_new
(
reader
,
NULL
,
conn
->
lc_memory
,
NULL
);
...
...
@@ -38,6 +55,8 @@ struct firefly_channel *firefly_channel_new(struct firefly_connection *conn)
return
NULL
;
}
chan
->
proto_decoder
=
proto_decoder
;
chan
->
proto_encoder
=
proto_encoder
;
// TODO: Fix this once Labcomm re-gets error handling
/* labcomm_register_error_handler_encoder(proto_encoder,*/
...
...
@@ -45,23 +64,6 @@ struct firefly_channel *firefly_channel_new(struct firefly_connection *conn)
/* labcomm_register_error_handler_decoder(proto_decoder,*/
/* labcomm_error_to_ff_error);*/
chan
->
local_id
=
next_channel_id
(
conn
);
chan
->
remote_id
=
CHANNEL_ID_NOT_SET
;
chan
->
state
=
FIREFLY_CHANNEL_READY
;
chan
->
important_queue
=
NULL
;
chan
->
important_id
=
0
;
chan
->
current_seqno
=
0
;
chan
->
remote_seqno
=
0
;
chan
->
proto_decoder
=
proto_decoder
;
chan
->
proto_encoder
=
proto_encoder
;
chan
->
conn
=
conn
;
chan
->
restricted_local
=
false
;
chan
->
restricted_remote
=
false
;
chan
->
auto_restrict
=
false
;
chan
->
enc_types
=
NULL
;
chan
->
seen_decoder_ids
=
NULL
;
chan
->
n_decoder_types
=
0
;
return
chan
;
}
...
...
src/protocol/firefly_protocol_connection.c
View file @
fdd9817f
...
...
@@ -3,16 +3,17 @@
* @brief Connection related functions for the protocol layer.
*/
#include
<
protocol/firefly_protocol.h
>
#include
"
protocol/firefly_protocol.h
"
#include
<string.h>
#include
<
utils/firefly_errors.h
>
#include
"
utils/firefly_errors.h
"
#include
"utils/cppmacros.h"
#include
"protocol/firefly_protocol_private.h"
#include
"utils/firefly_event_queue_private.h"
static
int
firefly_connection_open_event
(
void
*
arg
)
{
struct
firefly_connection
*
conn
=
arg
;
...
...
@@ -23,6 +24,28 @@ static int firefly_connection_open_event(void *arg)
return
0
;
}
/*
* Used by reg_proto_sigs() below to "short circuit" the connection during
* the initial registration of protocol types.
*/
static
void
signature_trans_write
(
unsigned
char
*
data
,
size_t
size
,
struct
firefly_connection
*
conn
,
bool
important
,
unsigned
char
*
id
)
{
UNUSED_VAR
(
important
);
UNUSED_VAR
(
id
);
unsigned
char
*
cpy_data
=
FIREFLY_RUNTIME_MALLOC
(
conn
,
size
);
memcpy
(
cpy_data
,
data
,
size
);
protocol_data_received
(
conn
,
cpy_data
,
size
);
}
static
struct
firefly_transport_connection
sig_transport
=
{
.
write
=
signature_trans_write
,
.
ack
=
NULL
,
.
open
=
NULL
,
.
close
=
NULL
};
struct
firefly_connection
*
firefly_connection_new
(
struct
firefly_connection_actions
*
actions
,
struct
firefly_memory_funcs
*
memory_replacements
,
...
...
@@ -46,7 +69,14 @@ struct firefly_connection *firefly_connection_new(
firefly_labcomm_memory_free
(
lc_mem
);
return
NULL
;
}
conn
->
actions
=
actions
;
conn
->
actions
=
actions
;
conn
->
event_queue
=
event_queue
;
conn
->
chan_list
=
NULL
;
conn
->
channel_id_counter
=
0
;
conn
->
lc_memory
=
lc_mem
;
conn
->
context
=
NULL
;
conn
->
transport
=
tc
;
conn
->
open
=
FIREFLY_CONNECTION_OPEN
;
if
(
memory_replacements
)
{
conn
->
memory_replacements
.
alloc_replacement
=
memory_replacements
->
alloc_replacement
;
...
...
@@ -68,6 +98,14 @@ struct firefly_connection *firefly_connection_new(
firefly_labcomm_memory_free
(
lc_mem
);
return
NULL
;
}
struct
firefly_transport_connection
*
orig_transport
;
orig_transport
=
conn
->
transport
;
conn
->
transport
=
&
sig_transport
;
init_firefly_protocol__signatures
();
transport_decoder
=
labcomm_decoder_new
(
reader
,
NULL
,
lc_mem
,
NULL
);
transport_encoder
=
labcomm_encoder_new
(
writer
,
NULL
,
lc_mem
,
NULL
);
...
...
@@ -87,14 +125,43 @@ struct firefly_connection *firefly_connection_new(
FIREFLY_FREE
(
conn
);
return
NULL
;
}
conn
->
event_queue
=
event_queue
;
conn
->
chan_list
=
NULL
;
conn
->
channel_id_counter
=
0
;
conn
->
transport_encoder
=
transport_encoder
;
conn
->
transport_decoder
=
transport_decoder
;
conn
->
lc_memory
=
lc_mem
;
conn
->
context
=
NULL
;
labcomm_decoder_register_firefly_protocol_data_sample
(
conn
->
transport_decoder
,
handle_data_sample
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_request
(
conn
->
transport_decoder
,
handle_channel_request
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_response
(
conn
->
transport_decoder
,
handle_channel_response
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_ack
(
conn
->
transport_decoder
,
handle_channel_ack
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_close
(
conn
->
transport_decoder
,
handle_channel_close
,
conn
);
labcomm_decoder_register_firefly_protocol_ack
(
conn
->
transport_decoder
,
handle_ack
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_restrict_request
(
conn
->
transport_decoder
,
handle_channel_restrict_request
,
conn
);
labcomm_decoder_register_firefly_protocol_channel_restrict_ack
(
conn
->
transport_decoder
,
handle_channel_restrict_ack
,
conn
);
labcomm_encoder_register_firefly_protocol_data_sample
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_request
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_response
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_ack
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_close
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_ack
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_restrict_request
(
conn
->
transport_encoder
);
labcomm_encoder_register_firefly_protocol_channel_restrict_ack
(
conn
->
transport_encoder
);
conn
->
transport
=
orig_transport
;
// TODO: Fix this once Labcomm re-gets error handling
/* labcomm_register_error_handler_encoder(conn->transport_encoder,*/
/* labcomm_error_to_ff_error);*/
...
...
@@ -102,12 +169,6 @@ struct firefly_connection *firefly_connection_new(
/* labcomm_register_error_handler_decoder(conn->transport_decoder,*/
/* labcomm_error_to_ff_error);*/
conn
->
transport
=
tc
;
conn
->
open
=
FIREFLY_CONNECTION_OPEN
;
reg_proto_sigs
(
conn
->
transport_encoder
,
conn
->
transport_decoder
,
conn
);
return
conn
;
}
...
...
src/protocol/firefly_protocol_labcomm.c
View file @
fdd9817f
...
...
@@ -38,11 +38,9 @@ struct transport_reader_context {
};
static
int
proto_reader_alloc
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
,
char
*
version
)
struct
labcomm_reader_action_context
*
context
)
{
UNUSED_VAR
(
context
);
UNUSED_VAR
(
version
);
UNUSED_VAR
(
r
);
return
0
;
}
...
...
@@ -70,7 +68,7 @@ static int proto_reader_fill(struct labcomm_reader *r,
static
int
proto_reader_start
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
const
struct
labcomm_signature
*
signature
,
void
*
value
)
{
UNUSED_VAR
(
context
);
...
...
@@ -93,7 +91,7 @@ static int proto_reader_end(struct labcomm_reader *r,
static
int
proto_reader_ioctl
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
const
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
{
UNUSED_VAR
(
action_context
);
...
...
@@ -259,17 +257,15 @@ static void trans_reader_free_backstack(struct labcomm_reader *r)
}
static
int
trans_reader_alloc
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
,
char
*
version
)
struct
labcomm_reader_action_context
*
context
)
{
UNUSED_VAR
(
context
);
UNUSED_VAR
(
version
);
UNUSED_VAR
(
r
);
return
0
;
}
static
int
trans_reader_free
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
)
struct
labcomm_reader_action_context
*
context
)
{
UNUSED_VAR
(
context
);
transport_labcomm_reader_free
(
r
);
...
...
@@ -277,7 +273,7 @@ static int trans_reader_free(struct labcomm_reader *r,
}
static
int
trans_reader_fill
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
)
struct
labcomm_reader_action_context
*
context
)
{
UNUSED_VAR
(
context
);
int
result
;
...
...
@@ -297,10 +293,10 @@ static int trans_reader_fill(struct labcomm_reader *r,
}
static
int
trans_reader_start
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
void
*
value
)
struct
labcomm_reader_action_context
*
context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
void
*
value
)
{
UNUSED_VAR
(
context
);
UNUSED_VAR
(
local_index
);
...
...
@@ -312,7 +308,7 @@ static int trans_reader_start(struct labcomm_reader *r,
}
static
int
trans_reader_end
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
)
struct
labcomm_reader_action_context
*
action_context
)
{
struct
transport_reader_context
*
ctx
;
ctx
=
action_context
->
context
;
...
...
@@ -333,10 +329,10 @@ static int trans_reader_end(struct labcomm_reader *r,
}
static
int
trans_reader_ioctl
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
{
UNUSED_VAR
(
local_index
);
UNUSED_VAR
(
remote_index
);
...
...
@@ -425,11 +421,9 @@ void transport_labcomm_reader_free(struct labcomm_reader *r)
}
static
int
comm_writer_alloc
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
char
*
labcomm_version
)
struct
labcomm_writer_action_context
*
action_context
)
{
UNUSED_VAR
(
action_context
);
UNUSED_VAR
(
labcomm_version
);
w
->
data_size
=
BUFFER_SIZE
;
w
->
count
=
w
->
data_size
;
...
...
@@ -470,7 +464,7 @@ static int comm_writer_flush(struct labcomm_writer *w,
static
int
proto_writer_start
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
int
index
,
struct
labcomm_signature
*
signature
,
const
struct
labcomm_signature
*
signature
,
void
*
value
)
{
struct
protocol_writer_context
*
ctx
;
...
...
@@ -544,7 +538,7 @@ static int proto_writer_end(struct labcomm_writer *w,
static
int
proto_writer_ioctl
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
int
index
,
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
const
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
{
UNUSED_VAR
(
w
);
...
...
@@ -612,7 +606,8 @@ void protocol_labcomm_writer_free(struct labcomm_writer *w)
static
int
trans_writer_start
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
int
index
,
struct
labcomm_signature
*
signature
,
void
*
value
)
int
index
,
const
struct
labcomm_signature
*
signature
,
void
*
value
)
{
UNUSED_VAR
(
w
);
UNUSED_VAR
(
action_context
);
...
...
@@ -640,7 +635,7 @@ static int trans_writer_end(struct labcomm_writer *w,
static
int
trans_writer_ioctl
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
int
index
,
struct
labcomm_signature
*
signature
,
int
index
,
const
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
arg
)
{
struct
transport_writer_context
*
ctx
;
...
...
src/test/labcomm_static_buffer_reader.c
View file @
fdd9817f
...
...
@@ -13,17 +13,15 @@ struct statbuf_context {
};
static
int
statbuf_alloc
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
char
*
labcomm_version
)
struct
labcomm_reader_action_context
*
action_context
)
{
UNUSED_VAR
(
r
);
UNUSED_VAR
(
action_context
);
UNUSED_VAR
(
labcomm_version
);
return
0
;
}
static
int
statbuf_free
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
)
struct
labcomm_reader_action_context
*
action_context
)
{
r
->
data
=
NULL
;
r
->
data_size
=
0
;
...
...
@@ -36,7 +34,7 @@ static int statbuf_free(struct labcomm_reader *r,
}
static
int
statbuf_fill
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
)
struct
labcomm_reader_action_context
*
action_context
)
{
UNUSED_VAR
(
action_context
);
int
result
=
r
->
count
-
r
->
pos
;
...
...
@@ -45,10 +43,10 @@ static int statbuf_fill(struct labcomm_reader *r,
}
static
int
statbuf_start
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
void
*
value
)
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
void
*
value
)
{
UNUSED_VAR
(
local_index
);
UNUSED_VAR
(
remote_index
);
...
...
@@ -59,7 +57,7 @@ static int statbuf_start(struct labcomm_reader *r,
}
static
int
statbuf_end
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
)
struct
labcomm_reader_action_context
*
action_context
)
{
UNUSED_VAR
(
action_context
);
if
(
r
->
count
<=
r
->
pos
)
{
...
...
@@ -72,12 +70,12 @@ static int statbuf_end(struct labcomm_reader *r,
}
static
int
statbuf_ioctl
(
struct
labcomm_reader
*
r
,
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
struct
labcomm_reader_action_context
*
action_context
,
int
local_index
,
int
remote_index
,
const
struct
labcomm_signature
*
signature
,
uint32_t
ioctl_action
,
va_list
args
)
{
int
result
;
...
...
@@ -142,8 +140,8 @@ struct labcomm_reader *labcomm_static_buffer_reader_new(struct labcomm_memory *m
/* }; */
struct
labcomm_reader
*
labcomm_static_buffer_reader_mem_new
(
void
*
context
,
void
*
(
*
m
)(
void
*
c
,
size_t
s
),
void
(
*
f
)(
void
*
c
,
void
*
p
))
void
*
(
*
m
)(
void
*
c
,
size_t
s
),
void
(
*
f
)(
void
*
c
,
void
*
p
))
{
struct
labcomm_reader
*
result
;
struct
labcomm_reader_action_context
*
action_context
;
...
...
src/test/labcomm_static_buffer_writer.c
View file @
fdd9817f
...
...
@@ -10,11 +10,9 @@
#define BUFFER_SIZE (512)
static
int
statbuf_alloc
(
struct
labcomm_writer
*
w
,
struct
labcomm_writer_action_context
*
action_context
,
char
*
labcomm_version
)
struct
labcomm_writer_action_context
*
action_context
)
{
UNUSED_VAR
(
action_context
);
UNUSED_VAR
(
labcomm_version
);
w
->
data_size
=
BUFFER_SIZE
;
w
->
count
=
w
->
data_size
;
...
...
@@ -28,7 +26,7 @@ static int statbuf_alloc(struct labcomm_writer *w,