I've developed a server for Intel Galileo in nodejs, which works perfectly fine on nodejs for windows.
The problem is when I tried to run it into Intel Galileo. It gives me this error:
dgram.js:248
throw new TypeError('First argument must be a buffer object.');
^
TypeError: First argument must be a buffer object.
at Socket.send (dgram.js:248:11)
at Socket.<anonymous> (/media/mmcblk0p1/Server/server2.js:21:12)
at Socket.g (events.js:180:16)
at Socket.EventEmitter.emit (events.js:92:17)
at startListening (dgram.js:141:10)
at dgram.js:216:7
at dns.js:72:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
code where the error appears:
var dgram=require("dgram");
var udpServer=dgram.createSocket("udp4");
udpServer.bind(8888, function(){
udpServer.setBroadcast(true);
udpServer.send("HIA",0,3,8888,"255.255.255.255",function(err){if(err)console.log(err)});
});
I'm trying to send a broadcast message with the text "HIA", but it seems it needs a buffer as parameter. This is not what the API says...
I guess the problem is that Intel Galileo has a different version of Node, but I've tried to update it unsuccessfully.
So use a Buffer
instead:
var message = new Buffer('HIA');
udpServer.send(message, 0, message.length, ...)