{"id":13481,"date":"2023-01-04T14:00:40","date_gmt":"2023-01-04T08:30:40","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=13481"},"modified":"2023-08-19T16:47:21","modified_gmt":"2023-08-19T11:17:21","slug":"microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 154| Structure exercise implementation"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 32px; border-width: 0px; line-height: 45px;\"><span style=\"color: #000080;\"><strong>Structure exercise implementation<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: 0px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, let&#8217;s code the below exercise packet field extraction program.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Exercise:<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #801919;\">Write a program to decode a given 32bit packet information and print the values of different fields. Create a structure with member elements as packet fields as shown below.<\/span><\/strong><\/p>\n<figure id=\"attachment_13484\" aria-describedby=\"caption-attachment-13484\" style=\"width: 566px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-13484 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-1-1.png\" alt=\"Figure 1. Exercise\" width=\"566\" height=\"240\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png 1866w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1-300x127.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1-1024x434.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1-768x325.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1-600x254.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1-1536x650.png 1536w\" sizes=\"(max-width: 566px) 100vw, 566px\" \/><figcaption id=\"caption-attachment-13484\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Exercise<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">First I created a variable of uint32_t packetValue. And then I am getting that value from the user using scanf.&nbsp; We are inputting the number in hex format, so for the scanf I use %X.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">struct<\/span> Packet\r\n{\r\n&nbsp; &nbsp;<span style=\"color: #008000;\"> uint8_t<\/span> crc;\r\n&nbsp; &nbsp;<span style=\"color: #008000;\"> uint8_t<\/span> status;\r\n&nbsp; &nbsp; <span style=\"color: #008000;\">uint16_t<\/span> payload;\r\n&nbsp;<span style=\"color: #008000;\"> &nbsp; uint8_t<\/span> bat;\r\n&nbsp; &nbsp; <span style=\"color: #008000;\">uint8_t<\/span> sensor;\r\n&nbsp; &nbsp; <span style=\"color: #008000;\">uint8_t<\/span> longAddr;\r\n&nbsp; &nbsp;<span style=\"color: #008000;\"> uint8_t<\/span> shortAddr;\r\n&nbsp;<span style=\"color: #008000;\"> &nbsp; uint8_t<\/span> addrMode;\r\n};\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(void)\r\n{\r\n    <span style=\"color: #008000;\">uint32_t<\/span> packetValue ;\r\n  <span style=\"color: #ff00ff;\">  printf<\/span>(\"Enter the 32bit packet value:\");\r\n   <span style=\"color: #ff00ff;\"> scanf<\/span>(\"%X\",&amp;packetValue);<\/pre>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, I created the packet structure.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">CRC is 2 bits, but I have to use the <\/span><b>uint8<\/b><span style=\"font-weight: 400;\"> variable type. That is sufficient to store two bits.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And here the status is stored in uint8. Payload is 12 bits, so I have selected uint16 for that, like that I have used the data types.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Later we can see how we can optimize the bits using the bit fields.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, I created a structure variable packet. Let&#8217;s start decoding.&nbsp;<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\"><span style=\"color: #ff99cc;\">struct<\/span> <span style=\"color: #008000;\">Packet<\/span> packet;\r\n\r\npacket.crc = (<span style=\"color: #008000;\">uint8_t<\/span>) (packetValue &amp; 0x3);\r\npacket.status = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 2) &amp; 0x1 );\r\npacket.payload = (<span style=\"color: #008000;\">uint16_t<\/span>) ( (packetValue &gt;&gt; 3) &amp; 0xFFF );\r\npacket.bat = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 15) &amp; 0x7 );\r\npacket.sensor = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 18) &amp; 0x7 );\r\npacket.longAddr = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 21) &amp; 0xFF );\r\npacket.shortAddr = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 29) &amp; 0x3 );\r\npacket.addrMode = (<span style=\"color: #008000;\">uint8_t<\/span>) ( (packetValue &gt;&gt; 31) &amp; 0x1 );\r\n\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"crc       :%#x\\n\",packet.crc);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"status    :%#x\\n\",packet.status);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"payload   :%#x\\n\",packet.payload);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"bat       :%#x\\n\",packet.bat);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"sensor    :%#x\\n\",packet.sensor);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"longAddr  :%#x\\n\",packet.longAddr);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"shortAddr :%#x\\n\",packet.shortAddr);\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"addrMode  :%#x\\n\",packet.addrMode);<\/pre>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">First, calculate CRC. The CRC is the first 2 bits.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"color: #3b8718;\"><b>packet.crc = (uint8_t)(packetValue &amp; 0x3);<\/b><\/span><span style=\"font-weight: 400;\"> Here, I am interested in only the last two bits, that&#8217;s why I&#8217;m zeroing out all the other bits.&nbsp;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, status. Status is 1 bit, but it comes in the second position.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">How do you extract that?&nbsp; For that what you have to do is, let&#8217;s take the packet value and right shift by 2.&nbsp; Now that bit comes to the least significant bit position, and after that &amp; 0x1. That&#8217;s it.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.status = (uint8_t)((packetValue &gt;&gt; 2) &amp; 0x1);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And next is the packet payload. Payload starts from 3, so you have to shift by three. Now, you have to extract the first 12 bits. So, to extract 12 bits, what should be the mask value?&nbsp; F is 4 once, another F 8 once, and another F&nbsp; 12 once. So, FFF. Here the payload is of type&nbsp; uint16. So, I have to use uint16.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.payload = (uint16_t)((packetValue &gt;&gt; 3) &amp; 0xFFF);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The next one is BAT value. Now you have to shift at the right-hand side and the shift amount. You can calculate by adding previous bit widths. So, 12 plus 1 plus 2, 15. Here it is 15.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And you have to extract the first 3 bits. So, 7.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.bat = (uint8_t)((packetValue &gt;&gt; 15) &amp; 0x7);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Next is the sensor. You have to shift this value by 18.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.sensor = (uint8_t)((packetValue &gt;&gt;&nbsp; 18) &amp; 0x7);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, to extract the long address, you have to shift this value by 21 and the width is 8 bits. That&#8217;s why, I&#8217;m using FF as a mask value, so this is the long address.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.longAddr = (uint8_t)((packetValue &gt;&gt; 21) &amp; 0xFF);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And to extract the short address you have to shift by 29 and the short address is 2 bits.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.shortAddr = (uint8_t)((packetValue &gt;&gt; 29) &amp; 0x3);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And to address the address mode you have to shift by 31. That&#8217;s why I would use three here. After that to get the address mode packet values should be shifted by 31.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #3b8718;\"><b>packet.addrMode = (uint8_t)((packetValue &gt;&gt; 31) &amp; 0x1);<\/b><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">To print a 0x, you can give the # symbol in between %X. That would add to the zero cross symbol for the hex value, as shown above.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The Output is shown in Figure 2. Here it is printed in hex.&nbsp;<\/span><\/p>\n<figure id=\"attachment_13487\" aria-describedby=\"caption-attachment-13487\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-13487\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-4.png\" alt=\"Structure exercise in C 32-Bit Packet Fields\" width=\"550\" height=\"292\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4.png 857w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-600x319.png 600w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><figcaption id=\"caption-attachment-13487\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Output<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s print the size of this structure, the code is shown below. I think the sizeof this structure may be 9 or 10.&nbsp;<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\"><span style=\"color: #ff00ff;\">   printf<\/span>(<\/span>\"Size of struct is %I64u\\n\"<span style=\"color: #ff99cc;\">,sizeof<span style=\"color: #ffffff;\">(packet));&nbsp;<\/span> \r\n\r\n while<\/span>(getchar() != '\\n');\r\n  &nbsp;getchar();\r\n\r\n<span style=\"color: #ff99cc;\">  &nbsp;return<\/span> 0;\r\n&nbsp;}<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Size of the packet code<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The output shows 10 bytes, as shown in Figure 3. So, it consumes 10 bytes in memory.&nbsp;<\/span><\/p>\n<figure id=\"attachment_13489\" aria-describedby=\"caption-attachment-13489\" style=\"width: 623px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-13489\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-6.png\" alt=\"Structure exercise in C 32-Bit Packet Fields\" width=\"623\" height=\"249\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6.png 1523w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-300x120.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-1024x409.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-768x307.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-600x240.png 600w\" sizes=\"(max-width: 623px) 100vw, 623px\" \/><figcaption id=\"caption-attachment-13489\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Output<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Basically, the packet value that you entered was a 4-byte value (32 bits). And to store that in a structure format using various member elements you lost 6 bytes, isn&#8217;t it? It is taking 10 bytes for this structure.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, now we have to find out if is there any technique by which we can minimize this memory consumption. The answer for that is using bit fields with the structure, and that is our next discussion.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the next discussion, we&#8217;ll use the same structure, the same member element, but we will reduce the size of the struct. And I will show you how to do that in the following article.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; line-height: 30px;\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; border-width: 0px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span><span style=\"color: #0000ff;\">&nbsp;<\/span><\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Structure exercise implementation &nbsp; In this article, let&#8217;s code the below exercise packet field extraction program.&nbsp; Exercise: Write a program to decode a given 32bit packet information and print the values of different fields. Create a structure with member elements as packet fields as shown below. &nbsp; First I created a variable of uint32_t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-13481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Decoding 32-Bit Packet Fields: Structure Exercise Implementation<\/title>\n<meta name=\"description\" content=\"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Decoding 32-Bit Packet Fields: Structure Exercise Implementation\" \/>\n<meta property=\"og:description\" content=\"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-04T08:30:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-19T11:17:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1866\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 154| Structure exercise implementation\",\"datePublished\":\"2023-01-04T08:30:40+00:00\",\"dateModified\":\"2023-08-19T11:17:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/\"},\"wordCount\":792,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-1-1.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/\",\"name\":\"Decoding 32-Bit Packet Fields: Structure Exercise Implementation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-1-1.png\",\"datePublished\":\"2023-01-04T08:30:40+00:00\",\"dateModified\":\"2023-08-19T11:17:21+00:00\",\"description\":\"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-1-1.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-1-1.png\",\"width\":1866,\"height\":790,\"caption\":\"Figure 1. Exercise\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 154| Structure exercise implementation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Decoding 32-Bit Packet Fields: Structure Exercise Implementation","description":"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/","og_locale":"en_US","og_type":"article","og_title":"Decoding 32-Bit Packet Fields: Structure Exercise Implementation","og_description":"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-01-04T08:30:40+00:00","article_modified_time":"2023-08-19T11:17:21+00:00","og_image":[{"width":1866,"height":790,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 154| Structure exercise implementation","datePublished":"2023-01-04T08:30:40+00:00","dateModified":"2023-08-19T11:17:21+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/"},"wordCount":792,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/","name":"Decoding 32-Bit Packet Fields: Structure Exercise Implementation","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png","datePublished":"2023-01-04T08:30:40+00:00","dateModified":"2023-08-19T11:17:21+00:00","description":"Structure exercise implementation in C. Learn how to decoding a 32-bit packet and extract different fields using C programming. Understand the","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-1-1.png","width":1866,"height":790,"caption":"Figure 1. Exercise"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-program-decoding-32-bit-packet-fields-structure-exercise-implementation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 154| Structure exercise implementation"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/13481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=13481"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/13481\/revisions"}],"predecessor-version":[{"id":15536,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/13481\/revisions\/15536"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/13484"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=13481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=13481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=13481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}