接线方面
B7 — RX
语音模块配置
进入语音模块官网 ,官网地址, 配置词条和识别后的串口输出指令
随便选一个,然后下一步
选纯离线方案
选择SU-03T
最后点击发布版本即可
接下来下载SDK,烧录即可
代码如下:
将语音模块插入开发板并编程实现基础逻辑代码,添加串口读取一个字符的接口, myserialGetchar();
固件先和电脑调试助手配合,验证数据
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include "uartTool.h"
int fd;
void* readSerial()
{
char cmd;
while(1){
cmd = myserialGetchar(fd);
switch(cmd){
case 'N':
printf("next\n");
break;
case 'P':
printf("pre\n");
break;
case 'Z':
printf("zan\n");
break;
case 'Q':
printf("qu\n");
break;
}
}
}
int main(int argc, char **argv)
{
char deviceName[32] = {'\0'};
pthread_t readt;
if(argc < 2){
printf("uage:%s /dev/ttyS?\n",argv[0]);
return -1;
}
strcpy(deviceName, argv[1]);
if( (fd = myserialOpen(deviceName, 115200)) == -1){
printf("open %s error\n",deviceName);
return -1;
}
pthread_create(&readt, NULL, readSerial,NULL);
while(1){
sleep(10);
}
}
手机接入Linux热拔插相关
- 把手机接入开发板
- 安装adb工具,在终端输入adb安装指令: sudo apt-get install adb
- dmeg 能查看到手机接入的信息,但是输入adb devices会出现提醒
dinsufficient permissions for device: user in plugdev group; are your udev rules wrong? - 配置文件,以支持USB设备的热拔插,支持UDEV的机制
在 /etc/udev/rules.d 文件夹下创建规则文件
sudo vim 51-android.rules
在文件中添加内容 SUBSYSTEM==“usb”, ENV{DEVTYPE}==“usb_device”, MODE=“0666” - 在手机开发者选项中,打开USB调试,重新拔插手机 (多次点击软件版本号就可以打开开发者模式了,一定要安卓手机)
- 手机弹出调试提醒,点确认手机调试模式
用shell指令来操作手机屏幕,模拟手动滑屏幕
adb shell input swipe 540 1300 540 500 100 向下滑动540是水平的,1300是竖直方向,下 是 500
adb shell input swipe 540 500 540 1300 100 向上滑动
adb shell "seq 3 | while read i;do input tap 350 1050 & input tap 350 1050 & sleep 0.01;done;" 点赞
adb shell input keyevent 26 锁屏
最后的代码如下
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pthread.h>
#include "uartTool.h"
int fd;
void* readSerial()
{
char cmd;
while(1){
cmd = myserialGetchar(fd);
switch(cmd){
case 'N':
printf("next\n");
system("adb shell input swipe 540 1300 540 500 100");
break;
case 'P':
printf("pre\n");
system("adb shell input swipe 540 500 540 1300 100");
break;
case 'Z':
printf("zan\n");
system("adb shell \"seq 3 | while read i;do input tap 350 1050 &
input tap 350 1050 & sleep 0.01;done;\"");
break;
case 'Q':
printf("qu\n");
system("adb shell input keyevent 26");
break;
}
}
}
int main(int argc, char **argv)
{
char deviceName[32] = {'\0'};
pthread_t readt;
if(argc < 2){
printf("uage:%s /dev/ttyS?\n",argv[0]);
return -1;
}
strcpy(deviceName, argv[1]);
if( (fd = myserialOpen(deviceName, 115200)) == -1){
printf("open %s error\n",deviceName);
return -1;
}
pthread_create(&readt, NULL, readSerial,NULL);
while(1){
sleep(10);
}
}