Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tommy Olofsson
LabComm
Commits
2ed270e5
Commit
2ed270e5
authored
Dec 16, 2011
by
Sven Robertz
Browse files
read channel ID to reply on the same channel
parent
18916fef
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/simple/datagram/thr_example2.c
View file @
2ed270e5
...
...
@@ -40,8 +40,8 @@ static int encode(int argc, char *argv[]) {
else
{
p_thr_chn
=
thr_open_chn
(
dest_mac
,
chn_id
,
frag_size
,
freq
,
NULL
);
p_thr_chn2
=
thr_open_chn
(
dest_mac
,
17
,
frag_size
,
100
,(
thr_msg_handler_t
)
labcomm_decoder_decode_one
);
encoder
=
labcomm_encoder_new
(
labcomm_thr_writer
,
p_thr_chn
);
p_thr_chn2
=
thr_open_chn
(
dest_mac
,
chn_id
,
frag_size
,
freq
,(
thr_msg_handler_t
)
labcomm_decoder_decode_one
);
encoder
=
labcomm_encoder_new
(
labcomm_thr_writer
,
p_thr_chn
2
);
labcomm_encoder_register_simple_TwoInts
(
encoder
);
labcomm_encoder_register_simple_IntString
(
encoder
);
decoder
=
labcomm_decoder_new
(
labcomm_thr_reader
,
p_thr_chn2
);
...
...
@@ -79,9 +79,10 @@ static int encode(int argc, char *argv[]) {
static
void
handle_simple_TwoInts
(
simple_TwoInts
*
v
,
void
*
context
)
{
unsigned
char
*
src
=
get_sender_addr
((
struct
thr_chn_t
*
)
context
);
unsigned
char
ch_id
=
get_channel
((
struct
thr_chn_t
*
)
context
);
printf
(
"Got TwoInts. a=%d, b=%d
\n
"
,
v
->
a
,
v
->
b
);
printf
(
"... src addr: %x:%x:%x:%x:%x:%x
\n
"
,
src
[
0
],
src
[
1
],
src
[
2
],
src
[
3
],
src
[
4
],
src
[
5
]);
struct
thr_chan_t
*
ch
=
thr_open_chn
(
src
,
17
,
(
unsigned
short
)
50
,
(
unsigned
short
)
100
,
NULL
);
struct
thr_chan_t
*
ch
=
thr_open_chn
(
src
,
ch_id
,
(
unsigned
short
)
50
,
(
unsigned
short
)
100
,
NULL
);
struct
labcomm_encoder
*
enc
=
labcomm_encoder_new
(
labcomm_thr_writer
,
ch
);
labcomm_encoder_register_simple_TwoInts
(
enc
);
v
->
a
*=
2
;
...
...
lib/c/experimental/ThrottleDrv/throttle_drv.c
View file @
2ed270e5
...
...
@@ -404,3 +404,7 @@ int thr_read(struct thr_chn_t* thr_chn, unsigned char* data, int length)
unsigned
char
*
get_sender_addr
(
struct
thr_chn_t
*
ch
)
{
return
ch
->
last_sender_adr
;
}
unsigned
char
get_channel
(
struct
thr_chn_t
*
ch
)
{
return
ch
->
id
;
}
lib/c/experimental/ThrottleDrv/throttle_drv.h
View file @
2ed270e5
...
...
@@ -16,4 +16,5 @@ int thr_send(const struct thr_chn_t* thr_chn, const char* data, unsigned int len
int
thr_read
(
struct
thr_chn_t
*
thr_chn
,
unsigned
char
*
data
,
int
length
);
unsigned
char
*
get_sender_addr
(
struct
thr_chn_t
*
ch
);
unsigned
char
get_channel
(
struct
thr_chn_t
*
ch
);
#endif
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