diff --git a/examples/simple/datagram/thr_example2.c b/examples/simple/datagram/thr_example2.c index 74f752c47a492df5efde37dfaf9791f0b57b6773..3dc209dd192448751b9f4bc9a5de8e86e64f9cff 100644 --- a/examples/simple/datagram/thr_example2.c +++ b/examples/simple/datagram/thr_example2.c @@ -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_chn2); 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; diff --git a/lib/c/experimental/ThrottleDrv/throttle_drv.c b/lib/c/experimental/ThrottleDrv/throttle_drv.c index 5852d7306cba2dccc0c1faef1a4887d3e2a1a945..5ecbd185590aacce4c211b3567e90237fd777ca9 100644 --- a/lib/c/experimental/ThrottleDrv/throttle_drv.c +++ b/lib/c/experimental/ThrottleDrv/throttle_drv.c @@ -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; +} diff --git a/lib/c/experimental/ThrottleDrv/throttle_drv.h b/lib/c/experimental/ThrottleDrv/throttle_drv.h index e231ba0a7f36ed8df24a9555cb4ab0d9507110b7..7ab0439550b90a2384f1ca3db4586dbe38d32aff 100644 --- a/lib/c/experimental/ThrottleDrv/throttle_drv.h +++ b/lib/c/experimental/ThrottleDrv/throttle_drv.h @@ -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