当前位置:网站首页>Detailed analysis of message signals occupying multiple bytes and bits
Detailed analysis of message signals occupying multiple bytes and bits
2022-06-30 07:06:00 【Programmer straw hat】
In the actual application message parsing program, it is necessary to account for 20 Bit for data analysis , Because I haven't written the program here for message parsing for a long time, I still have a good time , The calculation process is now recorded for your reference , It can be used when a message signal occupying multiple bytes is encountered during subsequent parsing .
Received message signal (20 position , Take two half bytes ):
1010 10110011 10111011
As shown above : Red is the first byte , Lower eight ; Blue is the second byte , Middle eight ; Green is the third byte , high 4 position .
1010 10110011 10111011 Convert decimal to zero 701371
10110011 10111011 Convert decimal to zero 46011
10111011 Convert decimal to zero 187
(10110011( Convert decimal to zero 179)) * 256 = 45824
46011 - 187 = 45824 It can be concluded that the middle eight bits are binary bit multiplication 256(2 The octave of ) Work out ;
After verification, the same principle can be obtained The upper four bits are the binary bits multiplied by 256*256(2 To the sixteenth power of ) Work out ;
if 20 The lowest digit 4 Bit is the upper four bits of the first byte filled , Move right 4 Bit to put it at the lowest 4 position , Last pass &0x0F Work out the result
The parsing process is that the lowest four digits are directly converted to decimal , The middle eight digits are converted to decimal and multiplied by 16( That is to say 2 Of 4 Power ), The high octave is converted to decimal and multiplied by 16*256( That is to say 2 Of 12 Power ), Add to get the final decimal result .
Of course , If the number of digits is small , There are more ways to think of , By shifting 、 Bit or 、 And / or cleverly disposed of , In addition, the binary data string of the message is directly converted to decimal number after being intercepted by the function , Another way of thinking is a good way .
边栏推荐
- Write about your feelings about love and express your emotions
- Xshell传输文件
- app quits unexpectedly
- Porting RT thread to s5p4418 (V): thread communication
- Egret P2 pit encountered by physical engine (1)
- Record one time of Tencent Test Development Engineer's automation interface test practice experience
- Essence of signal slot macros signal and slot
- What underlying technologies support the metauniverse?
- Connection Flood攻击原理
- js创建pdf文件
猜你喜欢

【docsify基本使用】

Jingwei Hengrun won the 10ppm quality award of paccar group again

Mysql5.7 compressed version installation tutorial

Connection flood attack principle

明天!“移动云杯”大赛空宣会开播!

Out of class implementation of member function of class template

Linux服务器安装Redis

Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)

Go common commands

Class template case - encapsulation of array classes
随机推荐
Record common problems: spaces in encodeuricomponent decoding and the use of Schema in third-party apps to invoke apps
Write and run the first go language program
【已解决】Failed! Error: Unknown error 1130
Skillfully use 5 keys to improve office efficiency
Introduction to go project directory structure
How to convert XML to JSON
【json-tutorial】第一章学习笔记
Cluster distributed
ROS system problem: rosdep init
【申博攻略】五.专家推荐信模板
【SemiDrive源码分析】【X9芯片启动流程】33 - Display模块 相关概念解析
0 basic job transfer software test, how to achieve a monthly salary of 9.5k+
IDEA import导入的类明明存在,却飘红?
Essence of signal slot macros signal and slot
Imxq Freescale yocto project compilation record
Egret P2 physical engine (1) small ball falling demo
【已解决】ERROR 1290 (HY000): Unknown error 1290
[Hot100]10. Regular Expression Matching
Use of sscanf function
踩坑记录:supervisor 日志返回信息:redis扩展未安装