-
Notifications
You must be signed in to change notification settings - Fork 129
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
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds #63
Comments
For sure @pokusew , here you can check a kind of approach, the code it's a little bit complex in real app:
It's something related to promises buffer offSet and the Promise.all([promises]) approach in Reader class but I'm lost and I can not figure out which is the real issue and how to solve it. Node version -> v11.6.0 I'm going to try upgrading version to v0.7.0 Thanks ;) PD: Debugging in version v0.7.0 discover that you controlled the error with:
So the issue comes when a previos transmit is done and then I try to read, I'm getting a response like that:
In this code side:
|
@Franx0 Thanks. 👍 What is the value of console.log(this.config.credit); // <- add this line and send me the output
const data = await this.reader.read(this.config.credit, 4); Could you print it using |
9 for example, any number between 7-22 that we can use to write/read data and need to be authenticated first 😉 |
Hi @Franx0, thanks for the reply. Sorry for the delay. The only explanation I can think of is that the authentication sequence fails (invalid password/token, malformed command) and then the card gets possibly into the IDLE state and needs to be reset in order to send any commands. The statement you wrote in the first post, would support that:
Could you please start the NFC with the logger and send me the complete output? 🙂 So that we can check 🔍 that all transmitted data (commands and responses) match the expectations. You can start the NFC with the logger like this: function log() {
console.log(...arguments);
}
const logger = {
log: log,
debug: log,
info: log,
warn: log,
error: log,
};
const nfc = new NFC(logger); // <- pass the logger here when initializing NFC Thank you. 🙂 |
hi @pokusew as you can see in the following log, there is something weird because the log return a 'transmit response receive' message but this is the flow: Transmit command to return default token from tag starts:
Digging in log I discover that I have the right response in PD: I figure out that 'trying to connect CONNECT_MODE_CARD 2' is the default behaviour of the lib in that process, isn't it? Cause I'm using the CONNECT_MODE_DIRECT protocol instead of CONNECT_MODE_CARD Thanks for all your support 💯 |
Hi @Franx0, could you please post a complete uncensored version of the console output? Also replace the previous logger with the improved version below: function log() {
console.log('[DEBUG]', ...arguments); // we can better distinguish debug logs in the output
}
const logger = {
log: log,
debug: log,
info: log,
warn: log,
error: log,
}; Thanks. 🙂 Card handling process: When a card is detected, the nfc-pcsc will automatically try to connect to it in CONNECT_MODE_CARD. The previous connection will be dropped. When the connection is successfully initiated, the card event is emitted (or eventually when autoProcessing is enabled, by default it is, the command to get card's UID will be transmitted, and only then a the card event containing card's uid will be emitted). Hope it makes it a bit clearer. Here is the example how the output should look like (this is basic example with the debug logging):
|
Hi @pokusew Here you have my log:
As you can see in the log comments it's neccessary to execute a second transmit in auth inside of a setTimeout function to make it possible.
I suspect that it could be possible because transmit command is an async process that might be not end when the second transmit order is being executed, make sense? Thanks so much @pokusew |
Hi @pokusew , here I go again :)
Last day I notice that after make a transmit command to get default key from an ultralight C tag, when I trigger the read method, I'm getting the following error from my nodeJS server.
It's like I exceeded the offSet of Buffer :S
The flow is like:
If I skip the number 3 step I can read the tag without any problem.
Thanks ;)
The text was updated successfully, but these errors were encountered: