⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cobs_decode.cpp

📁 COBS-consistent overhead byte stuffing
💻 CPP
字号:
// COBS_decode.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	
	unsigned char source[] = {0x05,0x04,0x04,0x01,0x01,0x02,0x02,0x05,0x28,0xA5,0x01,0xFF};		//Max length is 12,because after encoded,00 doesn't get into buffer when receiving
	unsigned char destination[12];										//Max length is 12, When less than 12, the last byte 00 can be ignored

	unsigned char length = sizeof(source);
	
	unsigned char *pEnd = source + length;
	unsigned char *pSource = source;
	unsigned char *pDestination = destination;


	while ( pSource < pEnd)
	{
		unsigned char index;
		unsigned code = *pSource++;

			for ( index = 1; index < code; ++index)
			{
				*pDestination = *pSource;
				++pDestination;
				++pSource;
			}

			*pDestination++ = 0;
	}

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -