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

📄 gsmdecode7bit.c

📁 GSM短信息7-bit解码程序
💻 C
字号:
#include <my.h>
//7-bit解码
//用于单片机控制手机模块进行GSM短信息7-bit解码。
//pSrc:源编码串指针
//pDst:目标编码串指针
//nSrcLength:源编码串长度
//返回:目标字符串长度
//pSrc:源字符串指针
//pDst:目标数据指针
//nSrcLength:源字符串长度
//返回:目标数据长度
uint gsmDecode7bit(const uchar *pSrc,uchar *pDst,uint nSrcLength)
{
 uint nSrc;
 uint nDst;
 uint nByte;
 uchar nLeft;
 nSrc=0;
 nDst=0;
 nByte=0;
 nLeft=0;
 while(nSrc<nSrcLength)
 {
  *pDst=((*pSrc<<nByte)|nLeft)&0x7f;
  nLeft=*pSrc>>(7-nByte);
  pDst++;
  nDst++;
  nByte++;
  if(nByte==7)
  {
   *pDst=nLeft;
   pDst++;
   nDst++;
   nByte=0;
   nLeft=0;
  }
  pSrc++;
  nSrc++;
 }
 *pDst=0;
 return nDst;
}
uint gsmBytes2String(const uchar *pSrc,uchar *pDst,uint nSrcLength)
{
 uint i;
 const uchar tab[]="0123456789ABCDEF";
 for(i=0;i<nSrcLength;i++)
 {
  *pDst++=tab[*pSrc>>4];
  *pDst++=tab[*pSrc&0x0f];
  pSrc++;
 }
 *pDst='\0';
 return nSrcLength*2;
}


⌨️ 快捷键说明

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