les adjunto el codigo que he hecho para las pruebas del sensor unicamente:
Código:
package com.example.pruebarfid2
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import com.rscja.deviceapi.RFIDWithUHFUART
class MainActivity : AppCompatActivity() {
private val rfid = RFIDWithUHFUART.getInstance()
private var isInventory = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.button)
button.setOnClickListener {
Toast.makeText(this, "Hola!", Toast.LENGTH_SHORT).show()
uhf()
}
}
private fun uhf() {
val result = rfid.init(this)
if (!result) {
Toast.makeText(this, "Conexión fallida", Toast.LENGTH_SHORT).show()
return
}
Toast.makeText(this, "Conexión exitosa", Toast.LENGTH_SHORT).show()
// Configuración de parámetros
// rfid.setFrequencyMode(xx)
// rfid.setPower(30)
if (rfid.startInventoryTag()) {
Toast.makeText(this, "Lectura iniciada", Toast.LENGTH_SHORT).show()
isInventory = true
ThreadInventory().start()
} else {
rfid.stopInventory()
Toast.makeText(this, "Error al iniciar la lectura", Toast.LENGTH_SHORT).show()
}
// ..............
rfid.stopInventory()
isInventory = false
// .................
// Desconectar UHF
rfid.free()
Toast.makeText(this, "UHF desconectado", Toast.LENGTH_SHORT).show()
}
private inner class ThreadInventory : Thread() {
override fun run() {
while (isInventory) {
val uhftagInfo = rfid.readTagFromBuffer()
if (uhftagInfo == null) {
Thread.sleep(20)
continue
}
val epc = uhftagInfo.epc
val rssi = uhftagInfo.rssi
// .....
}
}
}
}
y les dejo el error en consola cada vez que pulso el boton para la lectura del tag:
Código:
D/DeviceAPI: [MTK] load DeviceAPIM.so
I/DeviceAPI: UHF device = C72_6765
I/DeviceAPI: UHF_Init----------->DEVICE_C72_6765
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 165 0111000100, gpiolen=18
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
W/ple.pruebarfid2: type=1400 audit(0.0:1334): avc: denied { read write } for name="mt_gpio" dev="sysfs" ino=34038 scontext=u:r:untrusted_app:s0:c170,c256,c512,c768 tcontext=u:object_r:mt_gpio:s0 tclass=file permissive=0 app=com.example.pruebarfid2
W/ple.pruebarfid2: type=1400 audit(0.0:1335): avc: denied { read write } for name="mt_gpio" dev="sysfs" ino=34038 scontext=u:r:untrusted_app:s0:c170,c256,c512,c768 tcontext=u:object_r:mt_gpio:s0 tclass=file permissive=0 app=com.example.pruebarfid2
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 158 0111000100, gpiolen=18
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 155 0111000100, gpiolen=18
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 165 0111000100, gpiolen=18
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 24 0111000100, gpiolen=17
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 21 0111000100, gpiolen=17
E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
W/ple.pruebarfid2: type=1400 audit(0.0:1336): avc: denied { read write } for name="mt_gpio" dev="sysfs" ino=34038 scontext=u:r:untrusted_app:s0:c170,c256,c512,c768 tcontext=u:object_r:mt_gpio:s0 tclass=file permissive=0 app=com.example.pruebarfid2
I/chatty: uid=10170(com.example.pruebarfid2) identical 2 lines
W/ple.pruebarfid2: type=1400 audit(0.0:1339): avc: denied { read write } for name="mt_gpio" dev="sysfs" ino=34038 scontext=u:r:untrusted_app:s0:c170,c256,c512,c768 tcontext=u:object_r:mt_gpio:s0 tclass=file permissive=0 app=com.example.pruebarfid2
I/DeviceAPI: UHF_Init----------->DevIsOpen = 1
I/DeviceAPI: UHF_OpenAndConnect: uart = /dev/ttyS1
D/DeviceAPI_SerialPort: [SerialPort_Open] [13]: Permission denied
I/DeviceAPI: UHF uhf_uart_fd = -1
I/DeviceAPI_UHF: init() Uart = /dev/ttyS1
E/DeviceAPI_UHF: init() err UHFOpenAndConnect result:-1
W/ple.pruebarfid2: type=1400 audit(0.0:1340): avc: denied { read write } for name="ttyS1" dev="tmpfs" ino=12322 scontext=u:r:untrusted_app:s0:c170,c256,c512,c768 tcontext=u:object_r:ttyS_device:s0 tclass=chr_file permissive=0 app=com.example.pruebarfid2