read data from dev
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user