# How to caluclate XXXXXXX\_MASSAGE\_SIZE

**URL:** <https://forum.opencyphal.org/t/how-to-caluclate-xxxxxxx-massage-size/243>\
**Category:** Applications & Usage\
**Created:** [November 13, 2018, 10:40am UTC](https://forum.opencyphal.org/t/how-to-caluclate-xxxxxxx-massage-size/243 "2018-11-13T10:40:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skyyuzhang](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/skyyuzhang/32/65_2.png) [@skyyuzhang](https://forum.opencyphal.org/u/skyyuzhang)\
**Post date:** [November 13, 2018, 10:40am UTC](https://forum.opencyphal.org/t/how-to-caluclate-xxxxxxx-massage-size/243/1 "2018-11-13T10:40:25Z")

</div>

when i was learning basic tutorials I found that debug.value have a size in this code the buffer size was define to 62 i want to know why .

```auto
publishCanard(void)
{  
    static uint32_t publish_time = 0;
    static int step = 0;
    if(HAL_GetTick() < publish_time + PUBLISHER_PERIOD_mS) {return;} // rate limiting
    publish_time = HAL_GetTick();
    uint8_t buffer[UAVCAN_PROTOCOL_DEBUG_KEYVALUE_MESSAGE_SIZE];
    memset(buffer,0x00,UAVCAN_PROTOCOL_DEBUG_KEYVALUE_MESSAGE_SIZE);
    step++;
    if(step == 256) 
    {
        step = 0;
    }
    float val = sine_wave[step];
    static uint8_t transfer_id = 0;
    canardEncodeScalar(buffer, 0, 32, &val);
    memcpy(&buffer[4], "sin", 3);    
    canardBroadcast(&g_canard, 
                    UAVCAN_PROTOCOL_DEBUG_KEYVALUE_SIGNATURE,
                    UAVCAN_PROTOCOL_DEBUG_KEYVALUE_ID,
                    &transfer_id,
                    CANARD_TRANSFER_PRIORITY_LOW,
                    &buffer[0], 
                    7);
}

```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [November 13, 2018, 1:03pm UTC](https://forum.opencyphal.org/t/how-to-caluclate-xxxxxxx-massage-size/243/2 "2018-11-13T13:03:46Z")

</div>

Because that’s the maximum serialized size of this message. You can see that here: [https://github.com/UAVCAN/dsdl/blob/c1b8dcd4234b6551018684f868a9a4ab79119ee9/uavcan/protocol/debug/16370.KeyValue.uavcan](https://github.com/UAVCAN/dsdl/blob/c1b8dcd4234b6551018684f868a9a4ab79119ee9/uavcan/protocol/debug/16370.KeyValue.uavcan)
