read data from dev
This commit is contained in:
@@ -75,7 +75,8 @@ class TestRightExpReference : Fragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
override fun onClickPositiveButton() {
|
override fun onClickPositiveButton() {
|
||||||
startTakingReference()
|
// startTakingReference()
|
||||||
|
fetchHemoCubeResult()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -124,14 +125,14 @@ class TestRightExpReference : Fragment() {
|
|||||||
viewModel.progressBar.postValue(true)
|
viewModel.progressBar.postValue(true)
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
|
|
||||||
(activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.read,
|
(activity as TestRightActivity).mService.eventDrivenWrite2(
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
Log.d("mariya", data.toString())
|
Log.d("mariya", data.toString())
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
fullReadOutput.append(stringData)
|
fullReadOutput.append(stringData)
|
||||||
Log.d(TAG, "fullReadOutput = $fullReadOutput")
|
Log.d("mariya", "fullReadOutput = $fullReadOutput")
|
||||||
|
|
||||||
if (stringData.contains("OK", true)) {
|
if (stringData.contains("OK", true)) {
|
||||||
Log.d(
|
Log.d(
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class UsbService : Service() {
|
|||||||
// Todo: Uncomment this
|
// Todo: Uncomment this
|
||||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||||
mPort.open(connection)
|
mPort.open(connection)
|
||||||
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
// mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
|
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
//
|
//
|
||||||
isUsbConnected = true
|
isUsbConnected = true
|
||||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
||||||
@@ -113,6 +114,15 @@ class UsbService : Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun eventDrivenWrite2(listener: UsbServiceListener) {
|
||||||
|
this.listener = listener
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch (e: IOException) {
|
||||||
|
listener.onUsbError(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fun write(command: TestRightCommands){
|
// fun write(command: TestRightCommands){
|
||||||
// mPort.write(command.command.toByteArray(), Constants.WRITE_TIMEOUT_MILLIS)
|
// mPort.write(command.command.toByteArray(), Constants.WRITE_TIMEOUT_MILLIS)
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user