read data from device homocube

This commit is contained in:
smileomi18@gmail.com
2023-07-20 16:08:59 +05:30
parent a8e7d7d60b
commit 51b49a010c
2 changed files with 5 additions and 48 deletions

View File

@@ -52,7 +52,7 @@ class TestRightExpReference : Fragment() {
Log.e("mariya", "onViewCreated 1")
if (DataHolder.deviceType.equals(Constants.DEVICE_TYPE_HOMOCUBE) ) {
Log.e("mariya", "onViewCreated if")
fetchHemoCubeResult()
// fetchHemoCubeResult()
}
// if (DataHolder.deviceConstant == null) {
// viewModel.progressBar.postValue(true)
@@ -76,8 +76,7 @@ class TestRightExpReference : Fragment() {
}
override fun onClickPositiveButton() {
// startTakingReference()
fetchHemoCubeResult()
startTakingReference()
}
})
}
@@ -119,50 +118,6 @@ class TestRightExpReference : Fragment() {
// }
}
// private fun sendCmdToFetchDeviceConstant(recursive: Boolean) {
private fun fetchHemoCubeResult() {
Log.d("mariya", "fetchHemoCubeResult() called")
viewModel.progressBar.postValue(true)
val fullReadOutput = StringBuilder()
(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("mariya", "fullReadOutput = $fullReadOutput")
if (stringData.contains("OK", true)) {
Log.d(
TAG,
"onUsbRead() called in sendCmdToFetchDeviceConstant() found OK"
)
viewModel.mapDeviceConstants(fullReadOutput.toString())
viewModel.progressBar.postValue(false)
} else if (stringData.contains("FINE", true)) {
Log.d(TAG, "results = FINE")
viewModel.progressBar.postValue(false)
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again!!", Constants.ERROR_CRITICAL))
}
}
}
override fun onUsbError(e: Exception?) {
Log.e(TAG, "onUsbIoError() called in sendCmdToFetchDeviceConstant() -> $e")
viewModel.errorTriggered.postValue(ErrorMessage("Please Try Again this step", Constants.ERROR_NORMAL))
viewModel.progressBar.postValue(false)
}
})
}
// private fun sendCmdToFetchDeviceConstant(recursive: Boolean) {
private fun sendCmdToFetchDeviceConstant() {
Log.d(TAG, "sendCmdToFetchDeviceConstant() called")