You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running the following code and its seems to get slower and slower each time. The first few tags go very fast but after 30 or so I am waiting several seconds for a write. This is on a Mac M3 so should be pretty fast.
Any idea why this is happening.
nfc.on('reader', reader => {
console.log(`${reader.reader.name} device attached`);
let sequence = 0;
reader.on('card', async card => {
console.log(`Card detected:`, card);
try {
const data = await reader.read(4, 31 * 4);
console.log("Data read from tag:", toHexString(data));
if (data[12] == 0) {
console.log("Tag is empty, writing data...");
await reader.write(4, kTagData);
console.log("Data written to tag successfully.");
} else {
console.log("Tag is not empty.");
}
sequence++; // Increment sequence only on success
const tagInfo = { sequence: sequence, uid: card.uid };
win.webContents.send('nfc-tag', tagInfo);
} catch (error) {
console.error("Failed to read or write tag:", error);
} finally {
await reader.disconnect();
}
});
reader.on('error', err => {
console.error('An error occurred with the NFC reader:', err);
});
reader.on('end', () => {
console.log(`${reader.reader.name} device removed`);
});
});
The text was updated successfully, but these errors were encountered:
I am running the following code and its seems to get slower and slower each time. The first few tags go very fast but after 30 or so I am waiting several seconds for a write. This is on a Mac M3 so should be pretty fast.
Any idea why this is happening.
The text was updated successfully, but these errors were encountered: