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

网站投稿系统怎么做景区旅游门户网站建设方案

网站投稿系统怎么做,景区旅游门户网站建设方案,家具定制东莞网站建设,做律师事务所网站语音识别模块SU-03T 串口通信线程控制代码 inputCommand.h#xff08;输入控制指令#xff09;voiceControl.c#xff08;语音控制模块指令#xff09;main.c#xff08;主函数#xff09;编译运行结果 语音识别模块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.hstruct 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.hkea.cn/news/14365552/

相关文章:

  • 衡阳商城网站建设wordpress财付通
  • 网站栏目标签如何调用专业网站制作电话
  • 葫芦岛网站制作如何做seo搜索优化
  • 海门建网站公司小程序开发公司哪家正规
  • 网站特效360浏览器屏蔽某网站怎么做
  • 企业网站建立流程的第一步是什么官方网站做兼职
  • 西青做网站温州市网站
  • 找产品代理去哪个网站网站每年要交钱吗
  • 苏州做网站建设公司广州骏域网站建设专家 V
  • 专业建站模板商城网站备案需要什么
  • 网站模板展示商城网站建设是 什么软件
  • wordpress汉化器wordpress dx seo
  • 帝国做网站是选择静态还是伪静态网站开发需求规格说明书
  • 代理商门户网站开发设计wordpress主题下载
  • 中国最有名的网站建设公司俄罗斯网站开发
  • 新站网站建设外贸网站搭建服务商
  • 技术教程优化搜索引擎整站wordpress静态博客主题
  • 苏州园科生态建设集团网站全屏产品网站
  • 彩票网站的推荐怎么做mi2设计公司网站
  • 网站搭建是什么专业小程序怎么做出来的
  • wordpress网站在哪里修改密码石家庄建设银行网站
  • 龙溪网站制作网站链接交换
  • 扬中网站建设门户报价深圳餐饮设计公司排名
  • 图片生成链接seo整站优化外包公司
  • 网站排名优化软件企业网站怎样做可以搜索到
  • 南宁企业自助建站系统长沙网站搭建
  • 企业手机网站建设唐山微信小程序开发公司
  • 网站空间域名维护协议金属材料网站建设
  • 做设计的有什么网站wordpress推荐链接
  • 怎么做报名网站画册设计说明