androidkotlinserial-portinputstreammifare

Can not read whole id with Desfire EV2 4k card in Android app


I am trying to read id of Mifare Desfire EV2 card with custom reader attached via uart port to android tablet like device. Card id taken from android phone is: 04:28:3E:82:5F:6D:80 But from input stream in my app i get: 02:09:03:80:6D:5f:82:3A:03 Basicly from input stream i get second 4 bytes of id in reversed order, but i need to get whole 7 bytes. First three bytes and last two looks like some balast added by card reader. Here is code for reading from serial ports input stream:

while (currentCoroutineContext().isActive) {

                val inputStream = serialPort?.inputStream
                inputStream?.let {
                    val buffer = ByteArray(512)
                    val size: Int = inputStream.read(buffer)
                    if (size > 0) {
                        val cardID = buffer.take(size).toByteArray()
                        emit(Result.Value(cardID)
                    }
                }
                delay(500)
            }

Any idea what could be wrong ?


Solution

  • After clarification with manufacturer, card reader is programmed this way, so not problem at application side and without hw update there is no way to get whole card ID.