Hi I am running this on Windows 7.
I am trying to set up a dual communication towards an external serial
device on COM1.
What happens is that I will only receive (fs.read) the first incoming
character.
Before I receive that character I am not able to send any character,
but after receiving, I can send over and over again. But not receive
any more.

Here is the code:

var fs = require('fs');
var fd;

var Buffer = require('buffer').Buffer;
var buffer = new Buffer(100);

fs.open("\\\\.\\COM1", "w+", function(status, _fd){
  fd = _fd;
  if(status){
    console.log(status.message);
    return;
  }

  fs.read(fd, buffer, 0, 100, null, function(e,l,b){
    console.log("Read " + l + " bytes.");
    return;
  });

});

var buf = new Buffer('BBBB\n');
var stdin = process.openStdin();
stdin.on('data', function(chunk) {
  // For now I just send the four Bs when [Enter] is pressed.
  fs.write(fd, buf, 0, buf.length, null, function(err,written){
    if(err)throw err;
    console.log(written + " characters written.");
  });
});

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to