• 大小: 47KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-12
  • 语言: Java
  • 标签:

资源简介

基于android平台实现串口触摸屏的功能。在RK3026 ANDROID4.2平台上测试OK,没任何BUG。基本功能为:MCU通过串口将触摸屏的报点信息传递给平板电脑,平板电脑实现从串口得到的触摸信息上传到应用层。

资源截图

代码片段和文件信息

/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License Version 2.0 (the “License“);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing software
 * distributed under the License is distributed on an “AS IS“ BASIS
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG “SerioService“

#include 
#include 
#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include “SerioService.h“

#define SERIO_DEVICE  “/dev/ttyS0“

#define SERIO_RS232 0x02
#define SERIO_TOUCHIT213 0x38
#define SERIO_ANY 0xff

#define SERIO_PROTO SERIO_TOUCHIT213
#define SERIO_ID SERIO_ANY
#define SERIO_EXTRA SERIO_ANY

#define TIOCSETD_CPP      0x5423
#define SPIOCSTYPE 1074032897
#define N_MOUSE_CPP 2


namespace android {

// ---------------------------------------------------------------------------

SerioService::SerioService(bool shutdown) : Thread(false)
{
unsigned long ldiscdevt;
   fd = open(SERIO_DEVICE O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd < 0) { 
fprintf(stderr “inputattach: ‘%s‘ - %s\n“ 
SERIO_DEVICE strerror(errno)); 
return;  
}  
setline(fd CS8 B115200); 
ldisc = N_MOUSE_CPP; 
if (ioctl(fd TIOCSETD_CPP &ldisc)) { 
fprintf(stderr “inputattach: can‘t set line discipline\n“); 
return; 
}  
devt = SERIO_PROTO | (SERIO_ID << 8) | (SERIO_EXTRA << 16);  
if (ioctl(fd SPIOCSTYPE &devt)) { 
fprintf(stderr “inputattach: can‘t set device type\n“); 
return;  
}  
read(fd NULL 0);
}

SerioService::~SerioService() {
}


void SerioService::binderDied(const wp& who)
{
    // woah surfaceflinger died!
    ALOGD(“SurfaceFlinger died exiting...“);

    // calling requestExit() is not enough here because the Surface code
    // might be blocked on a condition variable that will never be updated.
    kill( getpid() SIGKILL );
    requestExit();
}

void SerioService::setline(int fd int flags int speed) 

struct termios t; 
tcgetattr(fd &t);  
t.c_cflag = flags | CREAD | HUPCL | CLOCAL;
t.c_iflag = IGNBRK | IGNPAR; 
t.c_oflag = 0; 
t.c_lflag = 0;  
t.c_cc[VMIN ] = 1; 
t.c_cc[VTIME] = 0; 
cfsetispeed(&t speed); 
cfsetospeed(&t speed); 
tcsetattr(fd TCSANOW &t);  
}  



bool SerioService::threadLoop()
{
// read(fd NULL 0);
    return true;
}

// ---------------------------------

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      20198  2014-08-16 17:17  串口触摸屏\原码\device\rockchip\rk30sdk\init.rc

     文件      11587  2014-08-22 11:05  串口触摸屏\原码\device\rockchip\rk30sdk\init.rk30board.rc

     文件        382  2014-08-16 17:17  串口触摸屏\原码\frameworks\base\cmds\serio\Android.mk

     文件       3069  2014-08-18 19:57  串口触摸屏\原码\frameworks\base\cmds\serio\SerioService.cpp

     文件       1397  2014-08-16 17:17  串口触摸屏\原码\frameworks\base\cmds\serio\SerioService.h

     文件       1313  2014-08-16 17:17  串口触摸屏\原码\frameworks\base\cmds\serio\serio_main.cpp

     文件       6400  2014-08-22 08:54  串口触摸屏\原码\kernel\drivers\input\serio\serport.c

     文件       8239  2014-08-22 08:54  串口触摸屏\原码\kernel\drivers\input\touchscreen\touchit213.c

     文件      84151  2014-08-22 08:54  串口触摸屏\原码\kernel\drivers\tty\tty_io.c

     文件      18013  2015-03-17 11:28  串口触摸屏\补丁\uart_touch.patch

     文件        367  2015-03-17 11:32  串口触摸屏\说明.txt

     目录          0  2015-03-17 11:20  串口触摸屏\原码\frameworks\base\cmds\serio

     目录          0  2015-03-17 11:24  串口触摸屏\原码\kernel\drivers\input\serio

     目录          0  2015-03-17 11:24  串口触摸屏\原码\kernel\drivers\input\touchscreen

     目录          0  2015-03-17 11:22  串口触摸屏\原码\device\rockchip\rk30sdk

     目录          0  2015-03-17 11:20  串口触摸屏\原码\frameworks\base\cmds

     目录          0  2015-03-17 11:24  串口触摸屏\原码\kernel\drivers\input

     目录          0  2015-03-17 11:25  串口触摸屏\原码\kernel\drivers\tty

     目录          0  2015-03-17 11:22  串口触摸屏\原码\device\rockchip

     目录          0  2015-03-17 11:20  串口触摸屏\原码\frameworks\base

     目录          0  2015-03-17 11:25  串口触摸屏\原码\kernel\drivers

     目录          0  2015-03-17 11:22  串口触摸屏\原码\device

     目录          0  2015-03-17 11:20  串口触摸屏\原码\frameworks

     目录          0  2015-03-17 11:24  串口触摸屏\原码\kernel

     目录          0  2015-03-17 11:26  串口触摸屏\原码

     目录          0  2015-03-17 11:27  串口触摸屏\补丁

     目录          0  2015-03-17 11:27  串口触摸屏

----------- ---------  ---------- -----  ----

               155116                    27



............此处省略0个文件信息

评论

共有 条评论

相关资源