高层数据链路控制协议的位填充要求 [英] bit stuffing requirement for HIgh Level Data link control protocol

查看:68
本文介绍了高层数据链路控制协议的位填充要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个用于在C#中进行位填充和填充的代码.任何帮助都会很棒.

关于

hi I need a code for bit stuffing and destuffing in c#. any help will be great.

Regards

推荐答案

有两种方法可以实现.
您可以使用二进制AND和OR运算符&"和"|"建立字节:
There are two ways to do it.
You can use the binary AND and OR operators "&" and "|" to build your bytes:
byte b = 0x20 | 0x04;

与左移和右移运算符<<"组合和>>"这些将使您能够做所需的事情.您显然可以定义常量值,以使所有这些内容都更具可读性.
替代方法是使用enum,这可以使您的代码更清晰:

Combined with the Shift Left and Shift Right operators "<<" and ">>" these will allow you to do what you need. You can obviously define constant values to make all this more readable.
The alternative is to use enum, which can make your code clearer:

   enum RXParms : byte
      {
      RxReady = 0,
      RxError = 1,
      RxOverflow = 2,
      RxClear = 3,
      RxCount = 4
      }
...
      RXParms rx = RXParms.RxReady + RXParms.RxClear;


这篇关于高层数据链路控制协议的位填充要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆