Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
2f14cbdc
Commit
2f14cbdc
authored
Jul 30, 2022
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
ca3d73fc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
6209 deletions
+63
-6209
JavaDemo.java
c/swig/JavaDemo.java
+59
-63
ademco_java_wrap.c
c/swig/ademco_java_wrap.c
+0
-6142
linux_java.sh
c/swig/linux_java.sh
+0
-0
win.bat
c/swig/win.bat
+0
-4
win_java.bat
c/swig/win_java.bat
+4
-0
No files found.
c/swig/JavaDemo.java
View file @
2f14cbdc
...
@@ -11,8 +11,14 @@ import java.util.*;
...
@@ -11,8 +11,14 @@ import java.util.*;
import
com.hb3344.ademco.*
;
import
com.hb3344.ademco.*
;
public
class
JavaDemo
{
public
class
JavaDemo
{
static
{
try
{
System
.
loadLibrary
(
"ademco"
);
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
err
.
println
(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n"
+
e
);
System
.
exit
(
1
);
}
}
private
Selector
selector
;
private
Selector
selector
;
private
Map
<
SocketChannel
,
Client
>
clients
;
private
Map
<
SocketChannel
,
Client
>
clients
;
...
@@ -72,64 +78,6 @@ public class JavaDemo {
...
@@ -72,64 +78,6 @@ public class JavaDemo {
clients
.
get
(
channel
).
onMsg
(
data
);
clients
.
get
(
channel
).
onMsg
(
data
);
}
}
static
{
try
{
System
.
loadLibrary
(
"ademco"
);
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
err
.
println
(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n"
+
e
);
System
.
exit
(
1
);
}
}
public
static
String
printable_bytes
(
byte
[]
b
){
return
printable_bytes
(
b
,
b
.
length
);
}
public
static
String
printable_bytes
(
byte
[]
b
,
int
length
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
length
;
i
++){
byte
c
=
b
[
i
];
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
((
b
[
i
]
>>>
4
)
&
0x0F
);
s
+=
HEX_STRING
.
charAt
(
b
[
i
]
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
char
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
int
c
=
b
[
i
]
&
0xFF
;
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
String
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
();
i
++){
char
c
=
b
.
charAt
(
i
);
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
void
test_libademco
(){
public
static
void
test_libademco
(){
// test parse
// test parse
{
{
...
@@ -202,8 +150,7 @@ public class JavaDemo {
...
@@ -202,8 +150,7 @@ public class JavaDemo {
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
JavaDemo
.
test_libademco
();
JavaDemo
.
test_libademco
();
int
port
=
12345
;
int
port
=
12345
;
if
(
args
.
length
>
0
){
if
(
args
.
length
>
0
){
...
@@ -348,6 +295,55 @@ public class JavaDemo {
...
@@ -348,6 +295,55 @@ public class JavaDemo {
}
}
}
}
public
static
String
printable_bytes
(
byte
[]
b
){
return
printable_bytes
(
b
,
b
.
length
);
}
public
static
String
printable_bytes
(
byte
[]
b
,
int
length
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
length
;
i
++){
byte
c
=
b
[
i
];
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
((
b
[
i
]
>>>
4
)
&
0x0F
);
s
+=
HEX_STRING
.
charAt
(
b
[
i
]
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
char
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
int
c
=
b
[
i
]
&
0xFF
;
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
String
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
();
i
++){
char
c
=
b
.
charAt
(
i
);
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
char
[]
append
(
char
[]
origin
,
char
[]
buf
){
public
static
char
[]
append
(
char
[]
origin
,
char
[]
buf
){
char
[]
dst
=
new
char
[
origin
.
length
+
buf
.
length
];
char
[]
dst
=
new
char
[
origin
.
length
+
buf
.
length
];
System
.
arraycopy
(
origin
,
0
,
dst
,
0
,
origin
.
length
);
System
.
arraycopy
(
origin
,
0
,
dst
,
0
,
origin
.
length
);
...
@@ -383,4 +379,4 @@ public class JavaDemo {
...
@@ -383,4 +379,4 @@ public class JavaDemo {
}
}
return
b
;
return
b
;
}
}
}
}
\ No newline at end of file
c/swig/ademco_java_wrap.c
deleted
100644 → 0
View file @
ca3d73fc
This diff is collapsed.
Click to expand it.
c/swig/linux.sh
→
c/swig/linux
_java
.sh
View file @
2f14cbdc
File moved
c/swig/win.bat
deleted
100644 → 0
View file @
ca3d73fc
mkdir com\hb3344\ademco
"C:\Users\Jack\Downloads\swigwin-3.0.12\swig.exe" -java -package com.hb3344.ademco -outdir com/hb3344/ademco -o ademco_java_wrap.c libademco.swig
cl -c ../ademco.c ademco_java_wrap.c -I"../" -I"%JAVA_HOME%include" -I"%JAVA_HOME%include/win32"
cl -LD ademco.obj ademco_java_wrap.obj -o ademco.dll
c/swig/win_java.bat
0 → 100644
View file @
2f14cbdc
mkdir com\hb3344\ademco
"C:\Users\Jack\Downloads\swigwin-3.0.12\swig.exe" -java -package com.hb3344.ademco -outdir com/hb3344/ademco -o libademco_java_wrap.c libademco.swig
cl -c ../ademco.c libademco_java_wrap.c -I"../" -I"%JAVA_HOME%include" -I"%JAVA_HOME%include/win32"
cl -LD ademco.obj libademco_java_wrap.obj -o ademco.dll
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