当前位置: 首页 > news >正文

腾讯企业邮箱账号网站怎样优化seo

腾讯企业邮箱账号,网站怎样优化seo,建设新北川网站,wordpress获取指定目录的文章语音识别模块SU-03T 串口通信线程控制代码 inputCommand.h(输入控制指令)voiceControl.c(语音控制模块指令)main.c(主函数)编译运行结果 语音识别模块SU-03T AI智能语音识别模块离线语音控制模块语音识别…

语音识别模块SU-03T
串口通信线程控制代码

  • inputCommand.h(输入控制指令)
  • voiceControl.c(语音控制模块指令)
  • main.c(主函数)
  • 编译
  • 运行结果

语音识别模块SU-03T

AI智能语音识别模块离线语音控制模块语音识别芯片声控模块SU-03T
离线语音模组 SU-03T开发文档

在这里插入图片描述
在这里插入图片描述

串口通信线程控制代码

inputCommand.h(输入控制指令)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>      
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <wiringPi.h>
#include <wiringSerial.h>struct InputCommand
{char commandName[128];                              //“控制方式”名char deviceName[128];               				//“设备工厂”名char command[32];                                   //存放指令int fd;                                             //存放文件描述符(串口/网络)int s_fd;									        //存放服务器套接字描述符char port[12];								        //存放端口号char ipAdress[32];							        //存放 IP地址char log[1024];                                     //日志int (*Init)(struct InputCommand *voice);            //“初始化”函数指针int (*getCommand)(struct InputCommand *voice);      //“获取指令”函数指针struct InputCommand *next;
};struct InputCommand* addVoiceControlToInputCommandLink(struct InputCommand *phead);		//“语音控制”加入指令链表函数声明

voiceControl.c(语音控制模块指令)

#include "inputCommand.h"// 语音控制模块初始化函数
int voiceInit(struct InputCommand *voice)
{int fd;// 打开串口设备 (voice->deviceName),波特率为 115200if ((fd = serialOpen (voice->deviceName, 115200)) < 0) { fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ; return 1 ; }voice->fd = fd; // 将文件描述符存储在 voice->fd 中return fd;
}// 从语音控制模块获取指令的函数 
int voiceGetCommand(struct InputCommand *voice)
{int nread = 0;// 从串口 (voice->fd) 读取数据到 voice->command 中nread = read(voice->fd, voice->command, sizeof(voice->command));//返回读取到数据的字节数,实际读取的指令放到了command里return nread;            
}// 全局变量,表示语音控制的输入命令对象 
struct InputCommand voiceControl = {.commandName = "voice",.deviceName = "/dev/ttyS5",.command = '\0',.Init = voiceInit,.getCommand = voiceGetCommand,.log = {'\0'},.next = NULL
};// 将语音控制对象加入到输入命令链表中的函数 
struct InputCommand* addVoiceControlToInputCommandLink(struct InputCommand *phead)	//“语音控制”(对象)加入指令方式链表函数
{if (phead == NULL) {return &voiceControl;}else {voiceControl.next = phead;phead = &voiceControl;return phead; // 如果链表不为空,将语音控制对象插入到链表头,并返回链表头的指针}
}

main.c(主函数)

#include <pthread.h>
#include "controlDevice.h"
#include "inputCommand.h"// 定义指令工厂初始链表头
struct InputCommand *pcommandHead = NULL;// 查找指令对象 by 名称
struct InputCommand* findCommandByName(char *name, struct InputCommand *phead) 
{struct InputCommand *tmp = phead;if (phead == NULL) {return NULL;} else {while (tmp != NULL) {if (strcmp(tmp->commandName, name) == 0) {return tmp;}tmp = tmp->next;}return NULL;}
}// 语音控制线程执行函数
void *voiceControlThread(void *data) 
{int nread;struct InputCommand *voiceHandler = NULL;// 查找名为 "voice" 的指令处理对象voiceHandler = findCommandByName("voice", pcommandHead);if (voiceHandler == NULL) {printf("find voiceHandler error\n");pthread_exit(NULL);} else {// 初始化语音控制功能if (voiceHandler->Init(voiceHandler) < 0) {printf("voiceControl init error\n");pthread_exit(NULL);} else {printf("voiceControl init success\n");}while (1) {// 清空指令缓存memset(voiceHandler->command, '\0', sizeof(voiceHandler->command));// 从语音控制模块获取指令nread = voiceHandler->getCommand(voiceHandler);if (nread == 0) {// 串口没有获取到指令printf("No voiceCommand received\n");} else {// 获取到指令printf("Get VoiceCommand --> %s\n", voiceHandler->command);}}}
}int main() 
{if (wiringPiSetup() == -1) {fprintf(stdout, "Unable to start wiringPi: %s\n", strerror(errno));return 1;}pthread_t voiceControl_thread;// 指令工厂初始化,将语音控制对象加入到指令链表中pcommandHead = addVoiceControlToInputCommandLink(pcommandHead);// 创建语音控制线程pthread_create(&voiceControl_thread, NULL, voiceControlThread, NULL);// 主函数等待语音控制线程退出pthread_join(voiceControl_thread, NULL);return 0;
}
http://www.hrbkazy.com/news/14536.html

相关文章:

  • 如何做购物网站推广山东百度推广代理商
  • 学习网站开发培训湖南正规seo公司
  • wordpress 说明文档成都百度提升优化
  • 天津哪家公司做企业网站凡科建站的优势
  • wordpress 移动商城主题安卓优化大师下载安装到手机
  • 网络架构部怎么理解搜索引擎优化
  • 小草小区二区三区四区谷歌优化培训
  • 安卓游戏开发软件长沙的seo网络公司
  • 微信公众号网站自己做导航条搜索引擎优化目标
  • 太原网站建设信息推荐中国seo第一人
  • 备案网站的规则贵阳做网络推广的公司
  • 网站建设推广唯心cidun8seo推广公司
  • 深圳app定制开发外包公司搜索引擎广告优化
  • mac网站开发环境seo入门培训学多久
  • 好看的扁平化网站seo关键词查询排名软件
  • 做行业网站赚钱网络营销外包推广
  • 免费建站cms推广专员是做什么的
  • 温州网站建设制作公司东莞网站提升排名
  • 可以做策略回测的网站本网站三天换一次域名
  • 东莞临时工最新招聘信息沈阳seo排名优化软件
  • 苏州网站建设要点做seo有什么好处
  • 怎样做外贸网站建设西安专业网络推广平台
  • 做网站需要哪些资质最近的热点新闻
  • 百度网址ip地址排名轻松seo 网站推广
  • 旅游网站策划方案西安seo排名
  • 温州做公众号和做网站的地方线上培训机构有哪些
  • 重庆网站制作公司电话百度搜索榜
  • 深圳定制网站个人建网站步骤
  • 阜阳手机网站制作如何写好软文
  • 南京做网站yuanmus2023年7 8月十大新闻