GRPS LLC层FCS CRC-24校验算法

#include <stdio.h>
#include <stdlib.h>

typedef	char           Int8;
typedef unsigned char  Uint8;
typedef unsigned short Uint16;
typedef short          Int16;
typedef unsigned int   Uint32;
typedef int            Int32;
typedef float          Float32;
typedef long double    Float64;
typedef long long      Int64;
typedef unsigned long long Uint64;


//Uint8  tx_data1[] = { 0x03,0xfb,0x01,0x00,0x0e,0x00,0x32,0x11,0x03,0x16,0x05,0xf0,0x1a,0x05,0xf0,0x1e,0x00,0x00,0x22,0x00,
//		              0x00,0x25,0x0c,0x29,0x10,0x0c,0xb6,0xa9};  //0xa9b60c
//Uint8 tx_data1[] = { 0x41,0xfb,0x01,0x00,0x0e,0x00,0x32,0x11,0x03,0x16,0x01,0x90,0x63,0x28,0x0b}; // 0x0b2863
//Uint8 tx_data1[] = { 0x41,0xfb,0x01,0x00,0x0e,0x00,0x32,0x11,0x03,0x16,0x01,0xf0,0x14,0x49,0x20}; // 0x204914
Uint8 tx_data1[] = { 0x41,0xfb,0x01,0x00,0x0e,0x00,0x32,0x11,0x03,0x16,0x05,0xf0,0xd4,0x29,0xcb};   // 0x29cbd4
//位翻转函数
Uint32 Reflect(Uint32 ref,Uint8 ch)
{
	int i;
	Uint32 value = 0;
	for( i = 1; i < ( ch + 1 ); i++ )
	{
		if( ref & 1 )
			value |= 1 << ( ch - i );
		ref >>= 1;
	}
	return value;
}


Uint32 crc24_bit(Uint8 *ptr, Uint32 len, Uint32 gx)
{
    Uint8 i;
	Uint32 crc = 0xffffffff;
    while( len-- )
    {
        for( i = 1; i != 0; i <<= 1 )
        {
            if( ( crc & 0x800000 ) != 0 )
			{
				crc <<= 1;
				crc ^= gx;
			}
            else
				crc <<= 1;
            if( ( *ptr & i ) != 0 )
				crc ^= gx;
        }
        ptr++;
    }
    return ( Reflect(crc,24) ^ 0xffffff );
}

int main()
{
	Uint8 *data = tx_data1;
    Uint8 dataLen = sizeof(tx_data1) -3;

	printf("Slow CRC by bit          : %08x\n",crc24_bit( data, dataLen, 0xbba1b5 ));//多项式0xbba1b5

}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Kubernetes中配置gRPC探针需要做以下步骤: 1. 创建gRPC服务和健康检查方法:首先,你需要在你的应用程序中创建一个gRPC服务,并实现一个健康检查方法,该方法可以返回一个表示应用程序健康状态的gRPC响应。 2. 创建gRPC探针配置文件:创建一个YAML或JSON格式的配置文件,用于定义gRPC探针的相关参数。配置文件中应包含以下信息: - `initialDelaySeconds`:探针启动前的等待时间,以秒为单位。 - `periodSeconds`:探针的调用频率,以秒为单位。 - `timeoutSeconds`:探测请求超时时间,以秒为单位。 - `successThreshold`:探测成功的连续次数。 - `failureThreshold`:连续失败的探测次数。 示例配置文件如下所示: ```yaml apiVersion: v1 kind: Pod metadata: name: grpc-pod spec: containers: - name: grpc-container image: your-image readinessProbe: tcpSocket: port: 50051 initialDelaySeconds: 5 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 3 ``` 在上述示例中,我们使用了TCP探针来检查gRPC服务的健康状态。你可以根据实际情况选择其他探针类型,如HTTP探针或命令探针。 3. 应用配置文件:在你的Kubernetes配置文件中,将上述gRPC探针配置文件添加到适当的位置。确保将其与容器的相关信息关联起来,以便Kubernetes可以正确调用和监控gRPC探针。 ```yaml apiVersion: v1 kind: Pod metadata: name: grpc-pod spec: containers: - name: grpc-container image: your-image ports: - containerPort: 50051 readinessProbe: tcpSocket: port: 50051 initialDelaySeconds: 5 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 3 ``` 4. 应用配置文件部署:使用kubectl或其他部署工具将配置文件应用到Kubernetes集群中。 以上是在Kubernetes中配置gRPC探针的基本步骤。你可以根据实际需求和应用程序的特点进行相应的调整和配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值