-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write single byte #7
Comments
@Ricky1966 I think you may want to check the develop branch at https://github.com/Carglglz/NFC_PN532_SPI/tree/develop, |
Hi, tks. |
Well in that case I don't know if writing a single byte is possible, I think
is the only way, but if you find out let me know 👍🏼 |
Rewrite the block is easy, for now I keep this way. But for change only one record in a NDEF Message with more than one record, is a little bit borring way. As you know the 5th block 0x04 have 4 bytes the first in my case is everytime 0x03, somewhere I've read this bytes meens start of NDEF Message and ISO 14443/3A, this is right? The second is the lenght of Message, without first and second bytes and the end 0xfe.Also this is right? |
I've just followed https://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef which I guess is what you're looking for |
I've already read that link, but is not explained how are setting the first bytes of ndef message. |
In the Adafruit link you gave me, some things I found on the net are not explained.
|
The thing is it doesn't look like writing less than a block is possible, i.e. 4. bytes (in case of ntags) is the minimum amount but if you find out that you can write a single byte (maybe in pn532 data sheet?) you could send a pull request and I may be able to test it 👍🏼 |
I'll try to write to NXP directly. Maybe they could help me for understand if is possible, if I don't wrong the PN532 chip comes from they. |
If you want my code, I'll gladly give it to you, write me at the email I put above and I'll send it to you. |
Hi, I put this post in the issuu, but actually it's not a real problem. I'm implementing a couple of new functions to your library the first one involves reading single, byte given the specific number of bytes to read. I need this because to read a multi-record tag, I need to know certain bytes. But now I find it difficult to write a certain byte.
The function :
def mifare_classic_read_block(self, block_number):
expects that you pass it the block and a 4-byte data array. I need to write the byte directly, is this possible?
I attach the lines of code that I wrote to be able to read the single byte
`
`
As you can see, I pass the position of the byte and the function returns the value.
This feature allows me to read a single byte memory dump, which makes things easier for me when parsing the NDEF Message.
From my research, an NDEF Message begins with 0x03h (should be a byte indicating the ISO 14333-3A encoding) the second byte indicates the length of the message, the actual message starts from the third byte.
The message is divided into records and records have a header and a payload.
The header is made up of N bytes, it depends on 8 bits which act as flags.
I made a couple of functions to establish the value of the header and then its subsequent bytes, The payload starts with the byte of the UTF8 or UTF16 encoding type, I have always encountered UTF8 which is 0x02h which are then the next two bytes for the encoding , in most cases, "en" for english.
finally the real payload starts.
in my test, I manage to extrapolate all single records, which I load into a multiple array, where the first value is an array representing the first bytes, in order:
-this byte 0x02h is the UTF8 encoding byte with two bytes for the language;
After this list, I put the payload as the second value in the list, and so on until the end of the records.
Now let's get to the point, if you help me write a function in NFC_PN532.py
that allows me to directly write the single byte in the memory location that interests me, I would be able to change the value of the payload. always staying within its length. This can be done knowing that the value of the record header contains the length of the payload.
Very important, the length of the payload starts from the UTF encoding byte, so a dump of a part of the NDEF message like this :
03 ... 91 01 06 54 02 65 6e 61 61 61
it means :
So, if I could write to the 10th byte, say 62, the payload would be UTF8 "en" baa instead of UTF8 "en" aaa
Thanks for your attention and I hope you can/want to help me
The text was updated successfully, but these errors were encountered: