c/c++实现window简易串口通信

控制台输出

COM打开成功!
0:退出  1:参数设置      4:发送指令
4
请输入指令:
165132344
2022-04-18 10:54:13     resp    16 51 32 34
0:退出  1:参数设置      4:发送指令
0:退出  1:参数设置      4:发送指令
recv    2022-04-18 10:54:21     recv    68 74 74 70 3A 2F 2F 77 77 77 2E 63 6D 73 6F 66 74 2E 63 6E       
0
读串口失败!

日志文件

2022-04-18 10:54:13	resp	16 51 32 34 
2022-04-18 10:54:21	recv	68 74 74 70 3A 2F 2F 77 77 77 2E 63 6D 73 6F 66 74 2E 63 6E 

串口数据

[2022-04-18 10:54:13.270]# RECV HEX>
16 51 32 34 
[2022-04-18 10:54:21.527]# SEND HEX>
68 74 74 70 3A 2F 2F 77 77 77 2E 63 6D 73 6F 66 74 2E 63 6E 

主代码实现main.cpp

主线程建立接收【副线程】,主线程负责发送指令,【副线程】负责接收指令。

#include <Windows.h>
#include <stdio.h>
#include<time.h>
#include <winnt.h>
#include "utils/FileDataBase.cpp"
#include "utils/data_handle.cpp"

HANDLE hCom;
// const char serial_port[6]="com10";//串口选择
const int baudRate=115200;//波特率
const int byteSize = 8; //每个字节有8位
const int parity = 1; //无奇偶校验位
const int stopBits = 1; //一个停止位

DWORD APIENTRY Thread1 ( LPVOID threadArg )
{
	time_t time_stamp = time(NULL);//时间
    struct tm *tm_time=localtime(&time_stamp);
    char s_time[0x30]={0};//字符型时间1997-01-02 03:04:05 06
    char s_day[0x10]={0};//时间天19970102
    int l_day=time_stamp/(24*60*60);
	char log_filename[0x100]={0};
	char log_data[0x1000]={0};

	bool bReadStat;
	DWORD recv_len;//从串口读取的字节数
	char recv_data[0x1000] = { 0 };//从串口接收到的数据

	while(1){
		bReadStat = ReadFile(hCom, recv_data, sizeof(recv_data), &recv_len, NULL);
		if (!bReadStat)
		{
			printf("读串口失败!");
			return FALSE;
		}else if(recv_len>0){

			time_stamp = time(NULL);//时间
			tm_time=localtime(&time_stamp);
			l_day=time_stamp/(24*60*60);
			sprintf(s_time,"%04d-%02d-%02d %02d:%02d:%02d",1900+tm_time->tm_year,(1+tm_time->tm_mon),tm_time->tm_mday,tm_time->tm_hour,tm_time->tm_min,tm_time->tm_sec);//时间格式00  
			sprintf(s_day,"%04d%02d%02d",1900+tm_time->tm_year,(1+tm_time->tm_mon),tm_time->tm_mday);//年月日
			sprintf(log_filename,"serial_%s.log",s_day);//日志文件名初始化
			
			sprintf(log_data,"%s\trecv\t",s_time);
			data_handle::char_to_hex(recv_data,recv_len,&log_data[strlen(log_data)]);
			sprintf(&log_data[strlen(log_data)],"\r\n");
			FileDataBase::log_(log_filename,log_data);//日志打印

			printf("recv\t%s",log_data);//日志输出
			// printf("%s\n",recv_data);
		}
		// Sleep(100);
	}
}

int main(void)
{
	HANDLE hComm;
	TCHAR serial_port[100];
	wsprintf(serial_port, TEXT("\\\\.\\COM%d"), 2);
	//COM1口//允许读//指定共享属性,由于串口不能共享,所以该参数必须为0//打开而不是创建 //属性描述,该值为FILE_FLAG_OVERLAPPED,表示使用异步I/O,该参数为0,表示同步I/O操作
	hCom = CreateFile(serial_port,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
	if (hCom == INVALID_HANDLE_VALUE){
		printf("打开COM失败!%s\n",serial_port);
		return 1;
	}else{printf("COM打开成功!\n");}
 
	SetupComm(hCom, 1024, 1024); //输入缓冲区和输出缓冲区的大小都是1024
 
	/*********************************超时设置**************************************/
	COMMTIMEOUTS TimeOuts;
	//设定读超时
	TimeOuts.ReadIntervalTimeout = MAXDWORD;//读间隔超时
	TimeOuts.ReadTotalTimeoutMultiplier = 0;//读时间系数
	TimeOuts.ReadTotalTimeoutConstant = 0;//读时间常量
	//设定写超时
	TimeOuts.WriteTotalTimeoutMultiplier = 1;//写时间系数
	TimeOuts.WriteTotalTimeoutConstant = 1;//写时间常量
	SetCommTimeouts(hCom, &TimeOuts); //设置超时
 
	/*****************************************配置串口***************************/
	DCB dcb;
	GetCommState(hCom, &dcb);
	dcb.BaudRate = baudRate; //波特率为9600
	dcb.ByteSize = byteSize; //每个字节有8位
	dcb.Parity = parity; //无奇偶校验位
	dcb.StopBits = stopBits; //一个停止位
	SetCommState(hCom, &dcb);
 
	//fd_set设置非阻塞
 	fd_set fd_set0={0};//服务器socket accept
	struct timeval tv0={1,0};//tv0.tv_sec=1;
	int select_return=0;//select返回值

	//
	char send_input[0x1000]={0};//这是从键盘接收到的数据
	char resp_data[0x1000]={0};//发送的数据

	time_t time_stamp = time(NULL);//时间
    struct tm *tm_time=localtime(&time_stamp);//本地时间
    char s_time[0x30]={0};//字符型时间1997-01-02 03:04:05 06
    char s_day[0x10]={0};//时间天19970102
    int l_day=time_stamp/(24*60*60);
	char log_filename[0x100]={0};
	char log_data[0x1000]={0};

	HANDLE hThread;  /* 记录线程句柄 */
	DWORD ThreadID;  /* 记录线程ID号 */
	DWORD waitingResult;  /* 等待线程退出的等待结果 */
	DWORD threadExitCode;  /* 记录线程的返回值 */
	char * aMessage = 0 ;

	/* 创建并启动线程ThreadOne,返回值为线程句柄,赋值给hThread */
	hThread = CreateThread ( NULL, 0L, Thread1, (LPVOID)aMessage, 0L, &ThreadID );
	if ( hThread == NULL )	{
		printf ("线程ThreadOne创建失败。错误代码:%lu\n", GetLastError() );
		return EXIT_FAILURE ;
	}
	while (1)
	{
		printf("0:退出\t1:参数设置\t4:发送指令\r\n");
		char ch=getchar();
		if(ch=='0'){//数据设置
			break;
		}else if(ch=='1'){//参数设置(未实现)
			// char ch=getchar();
		}else if(ch=='2'){//重新连接(未实现)
			
		}else if(ch=='4'){//数据发送
			// fgets(send_input,sizeof(send_input),stdin);
			printf("请输入指令:\r\n");
			scanf("%s",send_input);
			int input_len=strlen(send_input);
			int resp_len=data_handle::hex_to_char((unsigned char*)send_input, input_len, (unsigned char*)resp_data);
			DWORD resp_status=0;
			BOOL status = WriteFile(hCom,resp_data,resp_len,&resp_status,NULL);
			if(resp_status==resp_len&&resp_len!=0){
				time_stamp = time(NULL);//时间
				tm_time=localtime(&time_stamp);
				l_day=time_stamp/(24*60*60);
				sprintf(s_time,"%04d-%02d-%02d %02d:%02d:%02d",1900+tm_time->tm_year,(1+tm_time->tm_mon),tm_time->tm_mday,tm_time->tm_hour,tm_time->tm_min,tm_time->tm_sec);//时间格式00  
				sprintf(s_day,"%04d%02d%02d",1900+tm_time->tm_year,(1+tm_time->tm_mon),tm_time->tm_mday);//年月日
				sprintf(log_filename,"serial_%s.log",s_day);//日志文件名初始化serial_20010203.log
				
				sprintf(log_data,"%s\tresp\t",s_time);//日志数据初始化
				data_handle::char_to_hex(resp_data,resp_len,&log_data[strlen(log_data)]);//char数组转换为hex

				sprintf(&log_data[strlen(log_data)],"\r\n");
				FileDataBase::log_(log_filename,log_data);//日志打印
				printf("%s",log_data);//日志输出
			}
		}else if(ch==0x1b){//esc退出程序

		}else{
			// printf("没有这个方法:0\n");
		}
	}
	CloseHandle(hCom);
}

FileDataBase.cpp

文件数据库简易操作,个人喜好,与主流程必要相关无关,相关操作可以省略

#ifndef _FILE_DATABASE_
#define _FILE_DATABASE_

#include <stdio.h>
#include <string.h>
#include <io.h>
#include <direct.h>
// #include "data_handle.cpp"
namespace FileDataBase
{
    //创建文件夹
    void CreateFolder(char *folder)
    {
        if (_access(folder, 0) == -1) _mkdir(folder);// 文件夹不存在则创建文件夹
    }
    //创建日志
    void create(char *filename,char *filedata){
        FILE *fd = fopen(filename,"w+");
        if(fd != NULL){
            printf("%s is created.\n",filename);
        }
    }

    //获取文件长度
    int get_len(char *filename){
        FILE *file = fopen(&filename[0],"rb");//用r会出现读取不全,用rb数据不够准确
        if(file==NULL){
            return -1;
        }else{
            fseek(file,0,2);//定位到结尾
            int size=ftell(file);
            return size;
        }
    }
    //查询数据
    int read(char *filename,char *filedata){
        FILE *file = fopen(&filename[0],"rb");//用r会出现读取不全,用rb数据不够准确
        if(file==NULL){
            return -1;
        }else{
            fseek(file,0,2);//定位到结尾
            int size=ftell(file);
            fseek(file,0,0);//定位到开头
            int size1=fread(&filedata[0],sizeof(char),size,file);
            if(size1!=-1)filedata[size1]=0;
            // printf("\nsize1:%d",size1);
            fclose(file);//以只读方式打开,不需要写入
            return size;
            //远程53c25(342836)-f3
            //53b34(342836)-52ffff(339967)
        }
    }

    //插入数据
    int insert(char *filename,char *filedata){
        FILE *file = fopen(filename,"ab+");
        if(file==NULL){
            return -1;
        }else{
            fputs(filedata,file);
            fclose(file);
            return 0;
        }
    }

    //插入数据
    int log_(char *filename,char *filedata){
        FILE *file = fopen(filename,"ab");
        int ret=fputs(filedata,file);
        fclose(file);
        return ret;
    }

    //插入日志
    int log_(char *filename,char data){
        FILE *file = fopen(filename,"ab");
        if(file==NULL){
            return -1;
        }else{
            fputc(data,file);
            fclose(file);
            return 0;
        }
    }

    // int hex(char *filename,char *data,int len){
    //     FILE *file = fopen(filename,"ab");
      
    //     char* ch=new char[len*4];
    //     data_handle::char_to_hex(&data[0],&ch[0],len);//数据转换
    //     fputs(&ch[0],file);
    //     fclose(file);
    //     return 0;
    // }
    //修改数据
    //删除数据
}
#endif

data_handle.cpp

(数据处理,个人喜好,与主流程必要相关无关,本操作可以省略

#ifndef _data_handle_
#define _data_handle_
#include "structs.h"
#include "stdio.h"
#include <string.h>
#include <cstring>

#include "FileDataBase.cpp"

//char to str
const unsigned char char_to_str_L[0x100]={
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
    };

const unsigned char char_to_str_H[0x100]=
{
    '0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
    '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1',
    '2','2','2','2','2','2','2','2','2','2','2','2','2','2','2','2',
    '3','3','3','3','3','3','3','3','3','3','3','3','3','3','3','3',
    '4','4','4','4','4','4','4','4','4','4','4','4','4','4','4','4',
    '5','5','5','5','5','5','5','5','5','5','5','5','5','5','5','5',
    '6','6','6','6','6','6','6','6','6','6','6','6','6','6','6','6',
    '7','7','7','7','7','7','7','7','7','7','7','7','7','7','7','7',
    '8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8',
    '9','9','9','9','9','9','9','9','9','9','9','9','9','9','9','9',
    'A','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A',
    'B','B','B','B','B','B','B','B','B','B','B','B','B','B','B','B',
    'C','C','C','C','C','C','C','C','C','C','C','C','C','C','C','C',
    'D','D','D','D','D','D','D','D','D','D','D','D','D','D','D','D',
    'E','E','E','E','E','E','E','E','E','E','E','E','E','E','E','E',
    'F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F'
};
// char char_to_str_H[0x10]={};


//str —— char
const unsigned char str_to_char_H[0x100]=
{
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};


const unsigned char str_to_char_L[0x100]=
{
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};


char http_data[0x10000]={0};//接收的数据
// struct key_value *param1[10]={0};
namespace data_handle{
    int char_to_hex( char *src, int len,char *dest){
        // int index=0;
        for(int i0=0;i0<len;i0++){
            dest[3*i0+0]=char_to_str_H[(unsigned char)src[i0]];
            dest[3*i0+1]=char_to_str_L[(unsigned char)src[i0]];
            dest[3*i0+2]=' ';
        }
        dest[3*len]=0x00;
        return 3*len;
    }

    int char_to_hex(unsigned char *src,int len,unsigned char *dest){
        for(int i0=0;i0<len;i0++){
            dest[3*i0+0]=char_to_str_H[(unsigned char)src[i0]];
            dest[3*i0+1]=char_to_str_L[(unsigned char)src[i0]];
            dest[3*i0+2]=' ';
        }
        dest[3*len]=0x00;
        return 3*len;
    }

    void check_int(char *src){
        for(int i0=0;;i0++){
            if(src[i0]==0)break;
            if(src[i0]<'0'||src[i0]>'9'){
                src[i0]=0;
                break;
            }   
        }
    }

 void check_int(unsigned char *src){
        for(int i0=0;;i0++){
            if(src[i0]==0)break;
            if(src[i0]<'0'||src[i0]>'9'){
                src[i0]=0;
                break;
            }   
        }
    }
    void check_str(char *src){
        for(int i0=0;;i0++){
            if(src[i0]==0)break;
            if(src[i0]<'0'||(src[i0]>'9'&&src[i0]<'A')||(src[i0]>'Z'&&src[i0]<'a')||src[i0]>'z'){
                src[i0]=0;
                break;
            }
        }
    }

    void check_str(unsigned char *src){
        for(int i0=0;;i0++){
            if(src[i0]==0)break;
            if(src[i0]<'0'||(src[i0]>'9'&&src[i0]<'A')||(src[i0]>'Z'&&src[i0]<'a')||src[i0]>'z'){
                src[i0]=0;
                break;
            }
        }
    }

    //如果相等1,不相等0
    // int no_equal(char *str1,char *str2){
    //     int len_1=sizeof(str1);
    //     int len_2=sizeof(str2);
    //     unsigned char return0=1;
    //     if(len_1==len_2){
    //         for(int i0=0;(return0==0)&&(i0<len_1);i0++){
    //             if(str1[i0]==0&&str2[i0]==0)break;
    //             if(str1[i0]==str2[i0])return0=0;
    //         }
    //     }else{
    //        return0=0;
    //     }
    //     return return0;
    // }
    // //如果相等0,不相等1
    // int equal(char *str1,char *str2){
    //     unsigned char return0=0;
    //     for(int i0=0;(return0==1)&&(i0<len_1);i0++){
    //             if(str1[i0]==0&&str2[i0]==0)break;
    //         if(str1[i0]==str2[i0])return0=1;
    //     }
    //     return return0;
    // }

    // int db_handle(char *data_recv,struct db *data_resp){//数据库处理
    //     for(int i0=0;i0<;)
    //     }
     int str_to_char(unsigned char *src,unsigned int len,unsigned char *dest){
        // char* chars=new char[(len/2)+1];
        dest[len/2]=0x00;
        for(int i0=0;i0<(len/2);i0++){
            dest[i0]=str_to_char_H[src[2*i0]]+str_to_char_L[src[2*i0+1]];
            // printf("%02X=%c %c\n",chars[i0],str[2*i0],str[2*i0+1]);
        }
        return len/2;
    }

    int hex_to_char(unsigned char *src,int len,unsigned char *dest){
        unsigned int len1=0;
        unsigned char src1[0x1000]={0};
        for(int i0=0;i0<len;i0++){
            // printf("%02X",str_to_char_H[src[i0]]);
            if(str_to_char_H[src[i0]]!=0xff)src1[len1++]=src[i0];
        }
        // printf("\nlen:%d\n",len1);
        dest[len1/2]=0x00;
        for(int i0=0;i0<(len1/2);i0++){
            dest[i0]=str_to_char_H[src1[2*i0]]+str_to_char_L[src1[2*i0+1]];
            // printf("%02X=%c %c\n",dest[i0],src1[2*i0],src1[2*i0+1]);
        }
        return len1/2;

        // return str_to_char(dest1,index,dest);
    }

    int char_to_str(char *src,int len,char *dest){
        for(int i0=0;i0<len;i0++){
            int i10=i0<<1;
            int i11=(i0<<1)+1;
            dest[i10]=char_to_str_H[(unsigned char)src[i0]];
            dest[i11]=char_to_str_L[(unsigned char)src[i0]];
        }
        // str[len*2]=0x00;
        return len*2;
    }


  
   
    //字符串转换为int
    int str_to_int(char *str,int len){
        int return_int=0;
        for(int i0=0;i0<len;i0++){
            if(str[i0]>'9'||str[i0]<'0')return return_int;
            // printf("%d+%c\n",return_int,str[i0]);
            return_int=return_int*10+(int)str_to_char_L[str[i0]];
        }
        return return_int;
    }
    //字符串转换为大写char
    int str_to_char(char *str,int len,char *chars){
         // char* chars=new char[(len/2)+1];
        chars[len/2]=0x00;
        for(int i0=0;i0<(len/2);i0++){
            chars[i0]=(str_to_char_H[str[2*i0]])+str_to_char_L[str[2*i0+1]];
        }
        return len/2;
    }
    }#endif
    ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值