From 09036475003433d652fe89522ab25efdb50dd55d Mon Sep 17 00:00:00 2001 From: Mariya Date: Wed, 6 Dec 2023 16:08:52 +0530 Subject: [PATCH] Issues fixed --- .../presentation/hemocube/HemoCubeFragment.kt | 10 +++++----- .../hpostesting/presentation/testRight/UsbService.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt index bc27fc3..d7feff0 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/hemocube/HemoCubeFragment.kt @@ -39,7 +39,7 @@ class HemoCubeFragment : Fragment() { private var currentDeviceData: DeviceData? = null private var resultData: String = "" private var deviceSerialNo: String = "" - private var coeffiCients: String? = "" + private var coefficients: String? = "" private var isUsingExistingBuffer = false private var isTestOngoing = false private var startListening = MutableLiveData(false) @@ -327,7 +327,7 @@ class HemoCubeFragment : Fragment() { val result = validString.split(" ") val deviceLog = resultData if (result.size == 8) { - deviceSerialNo = result[2] + val deviceSerialNo = result[2] with(sharedPreferences.edit()) { putString(Constants.DEVICE_ID, deviceSerialNo) apply() @@ -361,11 +361,11 @@ class HemoCubeFragment : Fragment() { if (isOnline) { // Online mode, use coefficients from the server - coeffiCients = currentDeviceData?.coefficients?.get(0) + coefficients = currentDeviceData?.coefficients?.get(0) .toString() + ", " + currentDeviceData?.coefficients?.get(1).toString() } else { // Offline mode, provide default coefficients or handle as needed - coeffiCients = Constants.COEFFICIENTS[deviceSerialNo]?.get(0)?.get(0).toString() + "," + Constants.COEFFICIENTS[deviceSerialNo]?.get(1)?.get(0).toString() + coefficients = Constants.COEFFICIENTS[loginId]?.get(0).toString() + "," + Constants.COEFFICIENTS[loginId]?.get(1).toString() } // if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) { // if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) { @@ -396,7 +396,7 @@ class HemoCubeFragment : Fragment() { this.deviceRatio = deviceRatio this.calculatedRatio = calculateRatio(deviceRatio) // this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString() - this.coefficients = Constants.COEFFICIENTS[deviceId]?.get(0).toString() + "," + Constants.COEFFICIENTS[deviceId]?.get(1).toString() + this.coefficients = coefficients this.classificationResult = findResult(calculatedRatio) hemoCubeViewModel.messages.postValue(this.classificationResult) this.resultData = deviceLog 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 6f5e98e..5d3aab2 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 @@ -34,7 +34,7 @@ class UsbService : Service() { fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) { mPort = driver.ports[0] // Most devices have just one port (port 0) mPort.open(connection) - mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) + mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE) isUsbConnected = true Log.d(TAG, "My Usb Connected ${mPort.driver}")