Search code examples
ccountbufferuint8t

Passing received data to a buffer after reaching count


I used to work on java i'm new to C. I'm facing some issues.

Here i'm continuosly receiving data from a source. After reaching the count 3 i need to passthe whole data from count 1 to 3 to another function.

void check_msg_id( uint8_t *recvdata) {
    uint8_t buffer1[3];
    cnt=0;
    buffer1[cnt]=recvdata;
    cnt++;

    if (cnt==3) {
        cnt=0;
    }

}

How can i pass the data from all counts to a buffer? Any help will be appreciated. Thanks in advance


Solution

  • You can pass the data to another function by.

    void check_msg_id( uint8_t *recvdata) {
    uint8_t buffer1[3];
    cnt=0;
    buffer1[cnt]=recvdata;
    cnt++;
    
    if (cnt==3) {
        cnt=0;
      pass_data(buffer1);  //create a function
    }
    

    }

    You can pass this where ever you want.