Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DDC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GOKA HARSHITH
DDC
Commits
deaca6ea
Commit
deaca6ea
authored
Jun 27, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handler communication threads and process
parent
5f927c00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
101 deletions
+10
-101
app/src/main/java/com/example/harshith/ddc/ProcessService.java
...rc/main/java/com/example/harshith/ddc/ProcessService.java
+0
-23
app/src/main/java/com/example/harshith/ddc/ProcessThread.java
...src/main/java/com/example/harshith/ddc/ProcessThread.java
+0
-40
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+4
-37
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
...rc/main/java/com/example/harshith/ddc/ReceiveService.java
+6
-1
No files found.
app/src/main/java/com/example/harshith/ddc/ProcessService.java
deleted
100644 → 0
View file @
5f927c00
package
com.example.harshith.ddc
;
import
android.app.Service
;
import
android.content.Intent
;
import
android.os.IBinder
;
import
android.support.annotation.Nullable
;
/**
* Created by harshith on 18/6/16.
*/
public
class
ProcessService
extends
Service
{
@Override
public
void
onCreate
()
{
}
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
}
}
app/src/main/java/com/example/harshith/ddc/ProcessThread.java
deleted
100644 → 0
View file @
5f927c00
package
com.example.harshith.ddc
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.Message
;
/**
* Created by harshith on 18/6/16.
*/
public
class
ProcessThread
extends
Thread
{
int
[]
liveReadings
;
Handler
handler
;
GlobalClass
globalClass
;
public
ProcessThread
(
GlobalClass
globalClass
)
{
liveReadings
=
null
;
this
.
globalClass
=
globalClass
;
}
@Override
public
void
run
()
{
Looper
.
prepare
();
handler
=
new
Handler
(){
@Override
public
void
handleMessage
(
Message
msg
)
{
liveReadings
=
(
int
[])
msg
.
obj
;
L
.
m
(
liveReadings
.
toString
());
}
};
globalClass
.
setProcessHandler
(
handler
);
Looper
.
loop
();
while
(
true
){
if
(
liveReadings
!=
null
){
}
}
}
}
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
deaca6ea
...
...
@@ -26,11 +26,6 @@ public class ReceiveDataThread extends Thread {
this
.
handler
=
handler
;
this
.
globalClass
=
globalClass
;
stringBuilder
=
new
StringBuilder
();
}
public
void
setProcessHandler
(
Handler
processHandler
)
{
this
.
processHandler
=
processHandler
;
}
@Override
...
...
@@ -48,27 +43,19 @@ public class ReceiveDataThread extends Thread {
String
readMessage
=
new
String
(
buffer
,
0
,
bytes
);
stringBuilder
.
append
(
readMessage
);
convert
();
// ProcessThread processThread = new ProcessThread(globalClass);
// processThread.start();
//
// processHandler = globalClass.getProcessHandler();
while
(
true
)
{
bytes
=
inputStream
.
read
(
buffer
);
readMessage
=
new
String
(
buffer
,
0
,
bytes
);
stringBuilder
.
append
(
readMessage
);
convert
();
// if(processHandler != null) {
// processHandler.obtainMessage(1, readings).sendToTarget();
// }
// else {
// processHandler = globalClass.getProcessHandler();
// }
}
}
}
catch
(
IOException
e
){
readStatus
=
Constants
.
READ_STATUS_NOT_OK
;
Looper
.
prepare
();
handler
.
obtainMessage
(
Constants
.
READ_STATUS
,
readStatus
,
0
,
null
).
sendToTarget
();
Looper
.
loop
();
}
}
...
...
@@ -102,26 +89,6 @@ public class ReceiveDataThread extends Thread {
}
L
.
m
(
testConvert
);
stringBuilder
.
delete
(
0
,
endOfLineIndex
+
2
);
// int[] flex = new int[5];
// for (int i = 0; i != 5; i++) {
// try {
// flex[i] = readings[i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
//
// int[] mpu = new int[6];
// for (int i = 0; i != 6; i++) {
// try {
// mpu[i] = readings[5 + i];
// }
// catch (ArrayIndexOutOfBoundsException e) {
//
// }
// }
}
}
}
app/src/main/java/com/example/harshith/ddc/ReceiveService.java
View file @
deaca6ea
...
...
@@ -33,12 +33,17 @@ public class ReceiveService extends Service {
receiveDataThread
=
new
ReceiveDataThread
((
BluetoothSocket
)
message
.
obj
,
handler
,
globalClass
);
receiveDataThread
.
start
();
}
else
if
(
(
int
)
message
.
obj
==
Constants
.
CONNECTION_STATUS_NOT_CONNECTED
){
else
if
(
message
.
arg1
==
Constants
.
CONNECTION_STATUS_NOT_CONNECTED
){
Toast
.
makeText
(
getApplicationContext
(),
"Couldn't Connect to Dextera Domini, Check whether it is switched on"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
else
if
(
message
.
what
==
Constants
.
READ_STATUS
)
{
if
(
message
.
arg1
==
Constants
.
READ_STATUS_OK
){
}
else
if
(
message
.
arg1
==
Constants
.
READ_STATUS_NOT_OK
){
L
.
s
(
getBaseContext
(),
"Connection Lost"
);
}
}
}
};
...
...
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