Android串口操作说明
底层接口
使用底层接口
.,在该包中建立HardwareControler类。类的具体内容如下,该类中的方法用于操作底层接口。
public class HardwareControler {
/* Serial Port */
static public native int openSerialPort(String devName,
long baud, int dataBits, int stopBits);
/* LED */
static public native int setLedState(int ledID, int ledState);
/* PWM */
static public native int PWMPlay(int frequency);
static public native int PWMStop();
/* ADC */
static public native int readADC();
static public native int readADCWithChannel(int channel);
static public native int[] readADCWithChannels(int[] channels);
/* I2C */
static public native int openI2CDevice();
static public native int writeByteDataToI2C(int fd, int pos, byte byteData);
static public native int readByteDataFromI2C(int fd, int pos);
/* IO */
static public native int write(int fd, byte[] data);
static public native int read(int fd, byte[] buf, int len);
static public native int select(int fd, int sec, int usec);
static public native void close(int fd);
/* return 6410 or 210 */
static public native int getBoardType();
static {
try {
("friendlyarm-hardware");
} catch (UnsatisfiedLinkError e) {
("HardwareControler",
"libfriendlyarm-hardware library not found!");
}
}
}
串口API说明
接口名称
参数与返回值说明
功能说明
int openSerialPort(
String devName,
Android串口操作说明文档 来自淘豆网www.taodocs.com转载请标明出处.