Hi everyone,
I have a function named:
MFRC522_Write(WORK_BLOCK, data_write)
and a buffer named:
uchar data_write[16] = {SERIAL_R1, SERIAL_R2, ACC_CARD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}.
How I can write these data(with underline) with some variable(not constant!) data?
My project is to make a writer with which to write specific data on mifare 1k cards.
Thanks for anything advice.
Nobody has an answer?
It is not clear what you want to do
Can you write data to the cards ? If so what data do you want to write ?
Do you just want to change the values in the last 5 bytes of the array ? If so then where are you stuck ?
Thanks for reply.
If I use constant buffer data as below, I can write:
uchar data_write[16] = {SERIAL_R1, SERIAL_R2, ACC_CARD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xFD, 0x1C, 0x3D, 0xA4},
but if I use variable buffer data as below, they cannot be written:
uchar data_write[16] = {SERIAL_R1, SERIAL_R2, ACC_CARD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, var1, var2, var3, var4, var5}. These var1...var5, they have hex values when I want to write the tag.
SERIAL_R1, SERIAL_R2 is constant data:
#define SERIAL_R1 0xFA
#define SERIAL_R2 0x1F
I want to write different tags with different data with the same reader / writer. The var1 ... var5 data that I want to write on tags are correlated with the UID card and so results different data for each card.
These var1...var5, they have hex values when I want to write the tag.
Where and how are these variables declared and initialised
Please post a complete sketch that illustrates the problem
uchar var1;
.
.
.
uchar var5;
I try and:
u8 var1;
.
.
.
u8 var5;
but don't work.
I use CCS CCompiler.
Did you miss
Please post a complete sketch that illustrates the problem
What is a uchar data type ?
what is a u8 data type ?
UKHeliBob:
What is a uchar data type ?
what is a u8 data type ?
Thanks for reply.
uchar unsigned char
u8 unsigned (8 bits)
u16 unsigned (16 bits)
(CCS C Compiler)
I can't post the software.
My question is a general question: if I can use variable data inside buffer uchar data_write[16] in writing process of MIFARE 1K, by MFRC522.
What happens if you declare the array then separately set the value of the array element or elements that you need to be the value of variables ?
I don't find in CCS C Compiler Manual, how is declaration for array.
Can you provide this declaration?
Thanks again.
Can you provide this declaration?
You already have it
uchar data_write[16] = {SERIAL_R1, SERIAL_R2, ACC_CARD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
data_write[11] = something;
data_write[12] = somethingElse;
data_write[13] = somethingOld;
data_write[14] = somethingNew;
data_write[15] = somethingBlue;
Looks to me like this is what you are asking..
-jim lee
UKHeliBob:
You already haveuchar data_write[16] = {SERIAL_R1, SERIAL_R2, ACC_CARD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}Yes with constant data, this declaration works, but for variable data?
Jim Lee: I will try.
JimLee: data_write[11] = something;
If something is constant data_write[11] works, if something is a variable data, no.
If something is constant data_write[11] works, if something is a variable data, no.
You really need to post some code that proves that
No no no.. I think I see where he is getting stuck.
When you declare something IE create it. You can specify an initial CONSTANT value. This is what you have done.
Later you are able to stuff whatever value you want into it. That's what I was showing.
Try this AFTER you declare the array.
for (int i=11;i<16;i++) {
data_write[i] = i*2; // Or whatever you like to put in here.
}
-jim lee
JimLee:
Your suggestion with:
data_write[11] = something;
it was ok.
Yesterday when I used it I got it wrongly in the program. Now everythingthanks works well and I can move the sector key from the card in the microcontroller. This was the purpose of my post, which can be closed. Once again, thanks.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.