android 串口通讯2-对JNI封装JAVA的类,方便别人的调用
来源:互联网 发布:ubuntu 14.04安装ssh 编辑:程序博客网 时间:2024/05/22 19:33
前面忘记最后在jni目录,执行ndk-build了,执行这个后就会有workspace/uart/libs/armeabi下得到libuart.so了。
今天的目标是在uart/src/com/android/uart建一个Uartjni.java封装类,
内容如下:
package com.android.uart;
import android.util.Log;
public class Uartjni {
static
{
try
{
System.loadLibrary("uart");
Log.i("JIN","Trying to load libuart.so");
}
catch(UnsatisfiedLinkError ule)
{
Log.e("JIN","WARNING:could not load libuart.so");
}
}
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // open命令函数
// * Input: // /dev/ttyS6,/dev/ttyS7, /dev/rfid_rc522_dev
// * Output: //
// * Return: // 大于0成功。小于0失败
// * Others: // 无
// */
// -----------------------------------------------------------------------------------------------------------
public static native int openUart(String str);
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // close命令函数
// * Called By: //
// * Input: //
// * Output: //
// * Return: //
// * Others: // 无
// */
// -----------------------------------------------------------------------------------------------------------
public static native void closeUart();
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // 设置波特率命令函数
// * Called By: // { "1200", "2400", "4800", "9600","19200","38400","57600","115200","230400","921600"};
// * Input: //
// * Output: //
// * Return: // 返回大于0或者小于0的数据,小于0证明失败,这个时候JNI会自动close设备,如果需要打开则需要重新OPEN
// * Others: //
// */
// -----------------------------------------------------------------------------------------------------------
public static native int setUart(int baudrate);
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // 写命令函数
// * Called By: // 其中str为字符型数据
// * Input: //
// * Output: //
// * Return: //
// * Others: //
// */
// -----------------------------------------------------------------------------------------------------------
public static native int sendMsgUart(String str);
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // 读命令函数
// * Called By: //
// * Input: //
// * Output: //
// * Return: // NULL或者字符型数据
// * Others: //
// */
// -----------------------------------------------------------------------------------------------------------
public static native String receiveMsgUart();
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // 写16进制
// * Called By: //
// * Input: //
// * Output: //
// * Return: //
// * Others: // java中比如:int wfliao[] = new int[10]; 然后for(int i=0;i< 10; i++) wfliao[i]=0x12 ........
// */
// -----------------------------------------------------------------------------------------------------------
public static native int sendHexUart(int[] arr);
//------------------------------------------------------------------------------------------------------------
///*
// * Function: // 485 写16进制
// * Called By: //
// * Input: //
// * Output: //
// * Return: //
// * Others: // java中直接 传整形数,0----255的范围
// */
// -----------------------------------------------------------------------------------------------------------
public static native int send485HexUart(int number);
}
- android 串口通讯2-对JNI封装JAVA的类,方便别人的调用
- 对串口通讯的封装(C++)
- Java 对jni的调用
- android 串口通讯 JNI
- CnComm多线程串口通讯类的封装实现
- CnComm多线程串口通讯类的封装实现v0.02
- 将封装了envi功能的IDL类导出成java类,方便java调用
- JNI对HAL的封装
- jni c调用java 方法封装后出现的问题
- 转载别人对虚函数的解释,方便以后查找
- Android通过JNI实现与C语言的串口通讯操作蓝牙硬件模块
- vc 串口通讯类封装
- cocos2dx通过Jni调用Android的Java
- android jni 调用java的方法
- Android studio 简单方便的使用JNI调用c语言中的方法
- android JNI的调用
- 《Android JNI》05 在JNI中调用Java的函数
- android 串口通讯1-JNI 部分
- 客户测试环境使用小hack
- 14、Iterator跟ListIterator的区别
- 15、TCP/IP协议
- #pragma once与 #ifndef的区别
- iOS应用内付费(IAP)开发步骤列表
- android 串口通讯2-对JNI封装JAVA的类,方便别人的调用
- Redhat 5.4 Oracle 10g RAC 删除节点
- Android开发把项目打包成apk
- object-c小结
- 帐套和会计科目的理解
- hibernate 使用的设计模式(一) 观察者(50校招生网)
- 【转载】OpenCV配置 VS2010 VS2012 Win7 Win8
- 利用工具自动生成makefile文件
- Linux下Fork与Exec使用