BLC_CHANNEL.md 1.2 KB
Newer Older
Arnaud Blanchard's avatar
Arnaud Blanchard committed
1 2 3
Integration with blc_loop
=========================

Arnaud Blanchard's avatar
Arnaud Blanchard committed
4
This is for synchronization, for more information about blc_channels, see ( https://git.u-cergy.fr/blaar/blibs/blc_channel/blob/master/README.md ). 
Arnaud Blanchard's avatar
Arnaud Blanchard committed
5

Arnaud Blanchard's avatar
Arnaud Blanchard committed
6 7 8
output channel
--------------

Arnaud Blanchard's avatar
Arnaud Blanchard committed
9
Example defining a synchronous (':' double synchronization, '/' for asynchronization) channel of unsigned char ('UIN8') of 4096 values with no specific format ('NDEF').
Arnaud Blanchard's avatar
Arnaud Blanchard committed
10 11 12 13 14 15 16 17 18 19

    #include "blc_channel.h"
    #include "blc_program.h"
    
    ...
    
    blc_channel output;

    output.create_or_open(":toto", BLC_CHANNEL_WRITE, 'UIN8', 'NDEF', 1, 4096);
    output.publish();
20
    //Synchronize the BLC_COMMAND_LOOP with the output channel
Arnaud Blanchard's avatar
Arnaud Blanchard committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
    blc_loop_try_add_posting_semaphore(output.sem_new_data);

input channel
-------------

Open this same channel in reading synchronous (':', '/' for asynchronous) mode.

    #include "blc_channel.h"
    #include "blc_program.h"
    
    ...
    
    blc_channel input;

    input.open(":toto", BLC_CHANNEL_READ);
37
    //Synchronize the BLC_COMMAND_LOOP with the output channel
Arnaud Blanchard's avatar
Arnaud Blanchard committed
38 39 40
    blc_loop_try_add_waiting_semaphore(input.sem_new_data);
    blc_loop_try_add_posting_semaphore(input.sem_ack_data);