Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
trkall
/
T-Diagnostics
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
01444232
authored
May 24, 2021
by
Tref
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update with better structure
parent
6d3d0170
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
9 deletions
src/com/tDiagnostics/Main.java
src/com/tDiagnostics/Main.java
View file @
01444232
...
...
@@ -2,19 +2,73 @@ package com.tDiagnostics;
//import com.tDiagnostics.device.Connection;
import
com.tDiagnostics.device.ConnectDevice
;
import
com.fazecast.jSerialComm.SerialPort
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.charset.StandardCharsets
;
public
class
Main
{
public
void
main
(
String
[]
args
)
{
int
lastd
=
-
1
;
SerialPort
comPort2
=
SerialPort
.
getCommPort
(
"COM13"
);
comPort2
.
setBaudRate
(
9600
);
comPort2
.
setParity
(
SerialPort
.
NO_PARITY
);
comPort2
.
setNumDataBits
(
8
);
comPort2
.
setNumStopBits
(
1
);
comPort2
.
setComPortTimeouts
(
SerialPort
.
TIMEOUT_READ_SEMI_BLOCKING
,
500
,
500
);
comPort2
.
openPort
();
OutputStream
out2
=
comPort2
.
getOutputStream
();
InputStream
in2
=
comPort2
.
getInputStream
();
int
d
;
//in2 = InputStream.nullInputStream();
while
(
true
)
{
try
{
d
=
in2
.
read
();
if
(
d
!=
lastd
)
System
.
out
.
println
(
d
);
}
catch
(
IOException
e
)
{
d
=
-
1
;
}
//d = 203;
lastd
=
d
;
if
(
d
==
203
)
{
try
{
StringBuilder
str
=
new
StringBuilder
();
str
.
append
(
'D'
);
public
static
void
main
(
String
[]
args
)
{
// write your code here
char
c
=
1
;
ConnectDevice
connection
=
new
ConnectDevice
(
c
);
if
(
connection
.
startConnection
()){
System
.
out
.
println
(
"Success"
);
return
;
String
str2
=
str
.
toString
();
out2
.
write
(
str2
.
getBytes
(
StandardCharsets
.
UTF_8
));
System
.
out
.
println
(
str2
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
d
==
204
)
{
}
else
if
(
d
!=
-
1
&&
d
<
203
)
{
try
{
StringBuilder
str
=
new
StringBuilder
();
str
.
append
(
'G'
);
str
.
append
(
';'
);
String
str2
=
str
.
toString
();
out2
.
write
(
str2
.
getBytes
(
StandardCharsets
.
UTF_8
));
System
.
out
.
println
(
str2
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
System
.
out
.
println
(
"failed"
);
}
}
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