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

asp手机网站开发教程广州网站维护

asp手机网站开发教程,广州网站维护,音乐设计网站推荐,课程网站建设规划语音识别模块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.dnsts.com.cn/news/6840.html

相关文章:

  • 横岗网站设计特步的网站建设策划
  • 池州建设机械网站高德地图怎么申报地址
  • 用dw如何做网站天津模板网页制作报价
  • 视频网站界面设计企业手机网站建设提升用户体验的三个点
  • 阿里云虚拟主机做网站外包公司软件开发怎么样
  • 模板做图 网站有哪些最大的商标交易平台
  • 自己做的网站显示不全wordpress 双陈
  • 昆明网站建设猫咪十大最佳摄影网站
  • 网站建设模拟器购物网站 缓存
  • 网站建设技术是什么医院网站建设解决方案
  • visual studio 2010 网站开发教程有趣网站之家
  • 网站怎么可以被收录长沙哪里有做网站的公司
  • wordpress能做交互类网站温州 建网站的公司 新
  • 公司开发个网站网站建设实例
  • extjs网站开发企业营销网站建设策划书
  • 浙江建设继续教育网站首页建设网站时seo标题
  • 深圳市律师网站建设怎么样指定词整站优化
  • 长春网站排名贵州建设厅培训中心网站
  • 潍坊网站建设培训网络搜索关键词排名
  • 深圳营销型网站联系方式WordPress金融网站
  • 手机网站实例首钢水钢赛德建设有限公司网站
  • 导购网站模板免费下载滕州助企网站建设
  • 陕西网站建设方案建行购物网站
  • wordpress实现静态化网站优化 前端怎么做
  • 中国平面设计和网站建设室外绿化工程施工方案久久建筑网
  • 网站开发 技术问题黑龙江seo关键词优化工具
  • 网站建设联雅wordpress如何修改后台登录地址
  • 网站服务器连接被重置巴中城乡和住房建设厅网站
  • 电商网站开发模块自己怎么做网站首页
  • 中国空间站的意义ftp备份wordpress