-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathREADME
67 lines (49 loc) · 2.5 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Serial-To-USB-ANDROID is an implementation of Serial to USB driver using the Android USB Host API.
Copyright (C) 2012 JeD <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
REQUIREMENTS
--------------------------------------------------------------------------------------------
- ANDROID USB Host API (Android 3.1 or upper)
- no need to root the device
--------------------------------------------------------------------------------------------
END USE EXAMPLE
----------------------------------------------------------------------------------------
ISerial usb_serial=null;
usb_serial = new UsbSerial(UsbDeviceID.FT232RL,19200,mycontext);
usb_serial.open();
usb_serial.addEventListener(new SerialListener() {
@Override
public void incomingDataEvent(final SerialEvent evt) {
{
System.out.println("Event from Usb Serial"+new String(evt.read));
}
});
usb_serial.write("Hello World");
usb_serial.close();
------------------------------------------------------------------------------------------------
Serial-To-USB-Android Interface
------------------------------------------------------------------------------------------------
public interface ISerial {
public void open() throws SerialError;
public void open(String usbDeviceID,int baudrate) throws SerialError;
public void open(String _usbDeviceID) throws SerialError;
public abstract void open(UsbDeviceID usbDeviceID) throws SerialError;
public abstract void close();
public abstract void setBaudrate(int bitrate) throws SerialError;
public abstract boolean isConnected();
public abstract void write(byte[] data) throws SerialError;
public abstract void write(String data) throws SerialError;
public abstract byte[] read() throws SerialError;
public abstract void addEventListener (SerialListener listener);
public abstract void removeEventListener (SerialListener listener);
}