Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4e45eb68
authored
Aug 13, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加天波580C串口库
parent
774c5e33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
app/libs/armeabi/libcommon_serial.so
+0
-0
app/src/main/java/com/common/api/serial/Serial.java
+73
-0
No files found.
app/libs/armeabi/libcommon_serial.so
0 → 100644
View file @
4e45eb68
File added
app/src/main/java/com/common/api/serial/Serial.java
0 → 100644
View file @
4e45eb68
package
com
.
common
.
api
.
serial
;
import
java.io.File
;
import
java.io.FileDescriptor
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
public
class
Serial
{
private
static
boolean
mSupport
=
false
;
public
static
boolean
isSupport
()
{
return
mSupport
;
}
public
static
final
int
MODE_PRINTER
=
0
;
public
static
final
int
MODE_ICC
=
1
;
public
static
final
int
MODE_PINPAD
=
2
;
private
native
static
FileDescriptor
open
(
String
path
,
int
baudrate
,
int
flags
);
public
native
void
close
();
private
native
static
int
switch_mode
(
int
mode
);
/*
* Do not remove or rename the field mFd: it is used by native method
* close();
*/
private
FileDescriptor
mFd
;
private
FileInputStream
mFileInputStream
;
private
FileOutputStream
mFileOutputStream
;
public
Serial
(
String
path
,
int
baud
,
int
flags
)
throws
FileNotFoundException
,
SecurityException
,
IOException
{
// String cmd;
File
device
=
new
File
(
path
);
if
(!
device
.
exists
())
{
throw
new
FileNotFoundException
();
}
mFd
=
open
(
path
,
baud
,
flags
);
if
(
mFd
==
null
)
{
throw
new
IOException
();
}
mFileInputStream
=
new
FileInputStream
(
mFd
);
mFileOutputStream
=
new
FileOutputStream
(
mFd
);
}
public
InputStream
getInputStream
()
{
return
mFileInputStream
;
}
public
OutputStream
getOutputStream
()
{
return
mFileOutputStream
;
}
public
int
switchMode
(
int
mode
)
{
return
switch_mode
(
mode
);
}
static
{
try
{
System
.
loadLibrary
(
"common_serial"
);
mSupport
=
true
;
}
catch
(
Exception
e
)
{
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment