Currently having a problem in a app.
My app is designed to open an RFID reader on a Raspberry PI. It proceeds to read the incoming RFID tags.
The code is as follows;
// Socket.io server details
var io = require('socket.io').listen(3000);
// Serialport plugin declared and made a serialport variable
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
// Variable containing technical USB port details
var serialPort = new SerialPort("/dev/ttyUSB0", {baudrate: 2400, parser: serialport.parsers.readline("\n")} , false); // this is the openImmediately flag [default is true]
io.sockets.on('connection', function (socket) {
console.log('user connected');
socket.on('ping', function (data) {
serialPort.open(function () {
// Open notification
console.log('opening RFID scanner');
//Start listening
serialPort.on('data', function(data) {
if (data.trim() !== '') {
io.sockets.emit('pong', data);
socket.disconnect();
}
});
});
});
});
I open the app, and it works just fine. It constantly can read tags of a card. However; when I use a different card, Node.JS seems to use some kind of buffer.
An example;
I scan card A, return tag AAA. I scan card A, return tag AAA. I scan card B, return tag AAA. I scan card B, return tag AAA. I scan card B, return tag BBB (The one that was supposed to be returned).
This always seems to happen when changing tags.
Is there some kind of buffer in Node.JS, that stores a buffer of data that wasnt transmitted yet?
I'm aware of the .drain (callback), but how could I implement this in a proper way?
I am calling the Javascript window.open() function to load another url in a pop up window. When the users closes the popup window, I want the MyThanks() function to be called. How I can do this? My ...
I am calling the Javascript window.open() function to load another url in a pop up window. When the users closes the popup window, I want the MyThanks() function to be called. How I can do this? My ...
Let's say I have an HTML page, served up from example.com. It makes an javascript ajax request to targetServer.com Which server needs to return a Access-Control-Allow-Origin="(something)"? Is it the ...
Let's say I have an HTML page, served up from example.com. It makes an javascript ajax request to targetServer.com Which server needs to return a Access-Control-Allow-Origin="(something)"? Is it the ...
Hi I have this URL (top) I'm trying to use with "pinterest" they change the url (bottom). Does anybody know how I can change my (top) url to be the same as the "pinterest" url. Is there a Jquery ...
Hi I have this URL (top) I'm trying to use with "pinterest" they change the url (bottom). Does anybody know how I can change my (top) url to be the same as the "pinterest" url. Is there a Jquery ...
I'm trying to get JSON response from server using restangular. var baseAccounts = Restangular.one('getAllCustomers'); baseAccounts.getList().then(function(customers) { $scope.myData = ...
I'm trying to get JSON response from server using restangular. var baseAccounts = Restangular.one('getAllCustomers'); baseAccounts.getList().then(function(customers) { $scope.myData = ...