From fd8fbb863f2aa77491f9afd12c874857b599fb51 Mon Sep 17 00:00:00 2001 From: prisar Date: Wed, 19 Jul 2023 18:18:39 +0530 Subject: [PATCH] read data from dev --- .../presentation/testRight/TestRightExpReference.kt | 7 ++++--- .../hpostesting/presentation/testRight/UsbService.kt | 12 +++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpReference.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpReference.kt index 4c20c6d..8008399 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpReference.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightExpReference.kt @@ -75,7 +75,8 @@ class TestRightExpReference : Fragment() { } override fun onClickPositiveButton() { - startTakingReference() +// startTakingReference() + fetchHemoCubeResult() } }) } @@ -124,14 +125,14 @@ class TestRightExpReference : Fragment() { viewModel.progressBar.postValue(true) val fullReadOutput = StringBuilder() - (activity as TestRightActivity).mService.eventDrivenWrite(TestRightCommands.read, + (activity as TestRightActivity).mService.eventDrivenWrite2( object : UsbServiceListener { override fun onUsbRead(data: ByteArray?) { Log.d("mariya", data.toString()) data?.let { val stringData = String(it) fullReadOutput.append(stringData) - Log.d(TAG, "fullReadOutput = $fullReadOutput") + Log.d("mariya", "fullReadOutput = $fullReadOutput") if (stringData.contains("OK", true)) { Log.d( diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/UsbService.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/UsbService.kt index b7aeb54..68bbfed 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/UsbService.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/UsbService.kt @@ -38,7 +38,8 @@ class UsbService : Service() { // Todo: Uncomment this mPort = driver.ports[0] // Most devices have just one port (port 0) 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 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){ // mPort.write(command.command.toByteArray(), Constants.WRITE_TIMEOUT_MILLIS) // }