-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
linked responds bugfix #331
Conversation
Maybe there is something wrong in Travis CI......? It mistook variables' scope! |
src/MFRC522Extended.cpp
Outdated
|
||
result = TCL_TransceiveRBlock(tag, true, ackData, &ackDataSize); | ||
byte linked = 0; | ||
result = TCL_TransceiveRBlock(tag, true, ackData, &ackDataSize, linked); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linked
should be a pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very sorry to make such a silly mistake and I think I have fixed it.
src/MFRC522Extended.h
Outdated
@@ -93,7 +93,7 @@ class MFRC522Extended : public MFRC522 { | |||
///////////////////////////////////////////////////////////////////////////////////// | |||
StatusCode TCL_Transceive(PcbBlock *send, PcbBlock *back); | |||
StatusCode TCL_Transceive(TagInfo * tag, byte *sendData, byte sendLen, byte *backData = NULL, byte *backLen = NULL); | |||
StatusCode TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData = NULL, byte *backLen = NULL); | |||
StatusCode TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData = NULL, byte *backLen = NULL, byte* linked = NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use c++11 nullptr
instead of NULL
// Initialize the receiving data | ||
// TODO Warning: Value escapes the local scope | ||
in.inf.data = outBuffer; | ||
in.inf.size = outBufferSize; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
// Result is chained | ||
// Send an ACK to receive more data | ||
// TODO: Should be checked I've never needed to send an ACK | ||
|
||
while (in.prologue.pcb & 0x10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TCL_TransceiveRBlock
the var linked
is set:
*linked = in.prologue.pcb & 0x10;
and then at the end of the while it is checked
if(!linked) break;
But that's the same as
while (in.prologue.pcb & 0x10)
Or did I missed something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, the variables "in"s are local variables. So while (in.prologue.pcb & 0x10)
in function TCL_Transceive
will always be true although in.prologue.pcb
in function TCL_TransceiveRBlock
will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. You are right.
In 2-3 weeks I will have a closer look on it. Thanks so far for support :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay. I do not have the time to get deeper in this extended class.
I suggest changing linked to an boolean.
Please remove the not required space changes, it makes changes unnecessarily huge. Thanks.
while (in.prologue.pcb & 0x10) { | ||
byte ackData[FIFO_SIZE]; | ||
byte ackDataSize = FIFO_SIZE; | ||
|
||
result = TCL_TransceiveRBlock(tag, true, ackData, &ackDataSize); | ||
byte linked = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linked
seems more a boolean and should be
// Result is chained | ||
// Send an ACK to receive more data | ||
// TODO: Should be checked I've never needed to send an ACK | ||
|
||
while (in.prologue.pcb & 0x10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. You are right.
@@ -859,7 +856,7 @@ MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo *tag, byte *sendData | |||
/** | |||
* Send R-Block to the PICC. | |||
*/ | |||
MFRC522::StatusCode MFRC522Extended::TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData, byte *backLen) | |||
MFRC522::StatusCode MFRC522Extended::TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData, byte *backLen, byte* linked) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool* linked
@@ -913,7 +911,8 @@ MFRC522::StatusCode MFRC522Extended::TCL_TransceiveRBlock(TagInfo *tag, bool ack | |||
*backLen = in.inf.size; | |||
memcpy(backData, in.inf.data, in.inf.size); | |||
} | |||
|
|||
if(linked) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest for bool:
if(linked) {
*linked = ((in.prologue.pcb & 0x10)!=0x00);
}
@@ -93,7 +93,7 @@ class MFRC522Extended : public MFRC522 { | |||
///////////////////////////////////////////////////////////////////////////////////// | |||
StatusCode TCL_Transceive(PcbBlock *send, PcbBlock *back); | |||
StatusCode TCL_Transceive(TagInfo * tag, byte *sendData, byte sendLen, byte *backData = NULL, byte *backLen = NULL); | |||
StatusCode TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData = NULL, byte *backLen = NULL); | |||
StatusCode TCL_TransceiveRBlock(TagInfo *tag, bool ack, byte *backData = NULL, byte *backLen = NULL, byte* linked = nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool* linked
@@ -701,13 +702,11 @@ MFRC522::StatusCode MFRC522Extended::TCL_Transceive(PcbBlock *send, PcbBlock *ba | |||
|
|||
outBufferOffset += 2; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
@@ -807,17 +806,14 @@ MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo *tag, byte *sendData | |||
out.inf.size = 0; | |||
out.inf.data = NULL; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
// Check chaining | ||
if ((in.prologue.pcb & 0x10) == 0x00) | ||
return result; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
@@ -828,19 +824,19 @@ MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo *tag, byte *sendData | |||
*backLen = in.inf.size; | |||
memcpy(backData, in.inf.data, in.inf.size); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
result = TCL_Transceive(&out, &in); | ||
if (result != STATUS_OK) { | ||
return result; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the space
fix the bug when receiving linked responds