read data from dev

This commit is contained in:
prisar
2023-07-19 18:18:39 +05:30
parent b64c3fb471
commit fd8fbb863f
2 changed files with 15 additions and 4 deletions

View File

@@ -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(

View File

@@ -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)
// }