Orangepi Zero2——手机连接Linux与语音模块串口通信
文章目录
- 手机连接Linux
- adb控制指令
- 语音模块控制手机
- 语音模块配置
- 香橙派的配置
- 香橙派程序
手机连接Linux
1、把手机接入开发板
2、安装 adb 工具,在终端输入 adb 安装指令:
sudo apt-get install adb
3、dmesg 能查看到手机接入的信息,但是输入adb devices会出现提醒
dinsufficient permissions for device: user in plugdev group; are your udev rules wrong?
4、配置文件,以支持USB设备的热拔插,支持UDEV的机制
在/etc/udev/rules.d 文件夹下创建规则文件
cd /etc/udev/rules.d/
sudo vim 51-android.rules
在文件中添加内容 SUBSYSTEM==“usb”, ENV{DEVTYPE}==“usb_device”, MODE=“0666”
5、如果无法连接上,则需要在手机开发者选项中,打开USB调试,重新拔插手机,点击信任此设备
6、输入 adb devices 进行手机的连接
7、输入 adb shell 进行编程
adb控制指令
用 shell 指令来操作手机屏幕,模拟手动滑屏幕
1、向下滑动。从坐标点(540,1300)用100ms滑动到坐标点(540,500)
adb shell input swipe 540 1300 540 500 100
2、 向下滑动。从坐标点(540,500)用100ms滑动到坐标点(540,1300)
adb shell input swipe 540 500 540 1300 100
3、双击。点击坐标点(540,1050)两次,间隔0.1s
adb shell "seq 2 | while read i;do input tap 540 1050 & input tap 540 1050 & sleep 0.1;done;"
4、锁屏。
adb shell input keyevent 26
语音模块控制手机
设备连接图
语音模块配置
- 进入语音模块官网 http://www.smartpi.cn/#/,配置词条和识别后的串口输出指令,输出SDK
- 使用固件烧录工具,通过串口烧录进语音识别模块的SDK
- 先让语音固件先和电脑调试助手配合,验证数据
香橙派的配置
- 通过远程连接平台输出控制语句,检验是否可以操作手机完成相应的动作
香橙派程序
- 香橙派与语音固件通过串口进行通信
uartTest.c
#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 'L': printf("last\n"); system("adb shell input swipe 540 500 540 1300 100");break; case 'Z': printf("zan\n"); system("adb shell \"seq 2 | while read i;do input tap 540 1050 & input tap 540 1050 & sleep 0.1;done;\"");break; case 'Q': printf("quit\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);} }
uartTool.c
#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 "wiringSerial.h"char myserialGetchar (const int fd)
{char x ;if (read(fd , &x, 1) != 1)return -1 ;return x ;
}int myserialOpen (const char *device, const int baud)
{ struct termios options ; speed_t myBaud ; int status, fd ; switch (baud){ case 9600: myBaud = B9600 ; break ; case 115200: myBaud = B115200 ; break ; }if ((fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK)) == -1) return -1 ; fcntl (fd, F_SETFL, O_RDWR) ; // Get and modify current options: tcgetattr (fd, &options) ; cfmakeraw (&options) ; cfsetispeed (&options, myBaud) ; //设置波特率cfsetospeed (&options, myBaud) ; options.c_cflag |= (CLOCAL | CREAD) ; options.c_cflag &= ~PARENB ; //无校验位options.c_cflag &= ~CSTOPB ; //1位停止位options.c_cflag &= ~CSIZE ; //用数据位掩码清空数据位设置options.c_cflag |= CS8 ; //数据位为8options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG) ; options.c_oflag &= ~OPOST ; options.c_cc [VMIN] = 0 ; options.c_cc [VTIME] = 100 ; // Ten seconds (100 deciseconds) tcsetattr (fd, TCSANOW, &options) ; ioctl (fd, TIOCMGET, &status); status |= TIOCM_DTR ; status |= TIOCM_RTS ; ioctl (fd, TIOCMSET, &status); usleep (10000) ; // 10mS return fd ;
}void serialSendstring (const int fd, const char *s)
{ int ret;ret = write (fd, s, strlen (s)); if (ret < 0) printf("Serial Sendstring Error\n");
}int serialGetstring (const int fd, char *buffer)
{ int n_read; n_read = read(fd, buffer,32); return n_read;
}
uartTool.h
//香橙派获取语音固件发送的字符
char myserialGetchar (const int fd);int myserialOpen (const char *device, const int baud);void serialSendstring (const int fd, const char *s);int serialGetstring (const int fd, char *buffer);
Orangepi Zero2——手机连接Linux与语音模块串口通信相关推荐
- 【Orangepi Zero2 全志H616】语音刷抖音 / 手机连接Linux热拔插相关
目录 一.手机连接Linux步骤 二.adb控制指令 三.基于Linux串口实现语音刷抖音 1.语音模块控制详情 2.代码实现 一.手机连接Linux步骤 1.把手机接入开发板 2.安装adb工具,在 ...
- 手机测试连接linux系统,用CDMA 1X手机连接LINUX电脑上因特网
用CDMA 1X手机连接LINUX电脑上因特网 发表于:2007-05-26来源:作者:点击数: 标签: 下面讲述用cdma 1x手机连接linux电脑上因特网的步骤,如果幸运的话,设置不超过1分钟( ...
- 如何用CDMA 1X手机连接LINUX电脑上因特网
如何用CDMA 1X手机连接LINUX电脑上因特网 daweicheng leo@nj165.com 下面讲述用cdma 1x手机连接linux电脑上因特网的步骤,如果幸运的话,设置不超过1分钟(直接 ...
- 手机连接Linux系统 JuiceSSH - SSH Client(Android免费的SSH客户端)
手机连接Linux系统 JuiceSSH - SSH Client(Android免费的SSH客户端) 最近迷上Linux远程连接,以前经常尝试各种方式连接Linux服务器,发现手机上解决方案,Jui ...
- linux 嵌入式串口通信设计目的,基于linux的嵌入式串口通信.doc
PAGE 天津电子信息职业技术学院 <嵌入式软件编程>课程报告 课程名称:基于linux的嵌入式串口通信 课程代码: 115229 姓 名: 甘琦 学 号: 48 专 业: 物联网应用技术 ...
- linux 嵌入式串口通信,基于linux的嵌入式串口通信综述.doc
PAGE 天津电子信息职业技术学院 <嵌入式软件编程>课程报告 课程名称:基于linux的嵌入式串口通信课程代码: 115229 姓 名: 甘琦 学 号: 48 专 业: 物联网应用技术 ...
- STM32串口通信代码、ASCII码、XU4串口通信,printf只会转换为无符号类型,linux下的串口通信程序
1.其里面的的通信协议是是自己定的,这里 是检测到数据的结尾是以0x0d.0x0a结尾,则表示接受的数据完成了,这个数据是我想要的,这样子就不会出现一些错乱的数据信息.其中的0x8000.0x4000 ...
- 手机远程linux桌面,centos8安装xrdp远程桌面,Android手机连接linux桌面
前言 毫无疑问手机已经成为了生产力,有时我们想用安卓手机远程连接centos/ubuntu/debian等linux系统,该怎么办呢? ssh连接可以远程访问终端,xrdp和vnc可以让我们远程连接l ...
- 手机连接Linux教程,手机密钥连接linux主机
既然有了3G, 随时随地能上网了, 那很自然的我就希望能用手机管理服务器. Android手机本身就是Linux的一种, 连接另一台Linux服务器只是顺水行舟. 需要用到SSH客户端, 我的选择是C ...
最新文章
- JAVA中return与finally的先后关系
- 电子老鼠闯迷宫pascal解题程序
- win10 uwp unix timestamp 时间戳 转 DateTime
- 干货:产品经理怎么做才能在需求评审中少挨打?
- ant design vue 树形控件_官宣!vue.ant.design 低调上线
- 根据工序画出aoe网_这些金刚网纱窗竟然含“毒”!选错就得病
- 成为中国最好的Magento开发公司
- matlab遗传算法拟合,基于遗传算法的数据拟合在MATLAB环境中的实现
- linux定时器的实现方法
- atitit...触发器机制 ltrigger mechanism sumup .的总结O8f
- 【源码更新】活动报名登记预约问卷表单系统微信小程序支持导入导出自定义表单填报字段
- 熟练的mescroll
- 电子工程师 嵌入式开发者的嘉年华最强攻略
- 添加打印机,本地打印后台处理程序服务没有运行
- 配置访问路径自定义的swagger接口说明文档api
- dell更换硬盘识别不了新的硬盘
- afdsafdsafdsaf
- Hive 外部表的练习(多表关联查询,以及分组,子查询)
- SpringBoot 项目打成 .exe 程序,实战来了,超级详细!
- 低功耗蓝牙BLE-Advertising State/Scanning State