linux语音刷抖音

一、手机连接linux

1.安装工具:输入指令

sudo apt-get install adb

2、手机连接开发板子。

3、用dmesg查看是否接入 

 4、输入adb device

出现这种情况是因为手机没有开启USB调试功能,要在手机里的开发者模式打开USB调试功能。

打开后结果为:

 5、这种情况还是有问题的,根据解决方法

重新拔插后可以看出你的设备ID为2717:ff08(不同设备ID不同)

 配置好后、重新拔插USB

 这样就代表连接成功

6.进入adb shell

 错误解决:在手机开发者选项里选择允许USB调试

 如果想退出就输入exit

 

 二、adb控制指令

 用 shell 指令来操作手机屏幕,模拟手动滑屏幕

adb shell input swipe 540 1300 540 500 100

//向下滑动,从坐标(540,1300)以100毫秒的速度滑到(540,500)

adb shell input swipe 540 500 540 1300 100

//向上滑动,从坐标(540,500)以100毫秒的速度滑到(540,1300)

adb shell "seq 2 | while read i;do input tap 540 1050 & input tap 540 1050 & sleep 0.1;done;"

//双击。在(540 1050)的坐标点击2次间隔0.1s.

adb shell input keyevent 26

 //锁屏

 三、语音模块设置

使用的语音模块为SU-03T。

配置链接如下:

智能公元 

 相关配置:

 mySerial.c

#include<stdio.h>
#include"serialTool.h"
#include<pthread.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
int fd;

void* read_t()
{
	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 540 1050 & input tap 540 1050 & sleep 0.1;done;\"");//2个双引号要加转意字符“\”
			break;
		case'Q':
			printf("quit\n");
			system("adb shell input keyevent 26");
			break;

	}
	}
}

int main(int argc,char **argv)
{
	char serial[32] = {'\0'};
	pthread_t readt;

	if(argc<2)
	{
		printf("set:/dev/ttys?");
		return -1;
	}
	strcpy(serial,argv[1]);

	if((fd = mySerialOpen(serial,115200)) == -1)
	{
		printf("打开失败\n");
		return -1;
	}

	pthread_create(&readt,NULL,read_t,NULL);
	while(1){
		sleep(10);
	}
}

 

serialTool.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"

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 ;
    options.c_cflag &= ~CSIZE ;
    options.c_cflag |= CS8 ;
    options.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 serialPutString(const int fd, const char *s)
{ 
	int ret;
	ret = write (fd, s, strlen (s));
	if (ret < 0)
		printf("Serial Puts Error\n");
}
int serialGetString (const int fd,char * buffer)
{	
	int n_read;
	n_read = read(fd,buffer,32);
	return n_read;

}
char myserialGetchar (const int fd)
{
  char x ;

  if (read (fd, &x, 1) != 1)
    return -1 ;

  return x;
}

serialTool.h

int mySerialOpen (const char *device, const int baud);
void serialPutString (const int fd, const char *s);
int serialGetString (const int fd);
char myserialGetchar (const int fd);

编译运行对语音模块说出相应命令词即可。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值