Example #1
0
  phidgets.client = net.createConnection(params.port, params.host, function(){
    phidgets.client.setEncoding('utf8');
    phidgets.client.setKeepAlive("enable", 10000)
    phidgets.client.on('data', phidgets.handleData);
    phidgets.client.on('end', phidgets.handleConnectionEnd);
    phidgets.client.on('close', phidgets.handleConnectionEnd);
    phidgets.client.on('error', function(e){ throw "Error with connection to Phidget Board"; });

    phidgets.client.write("995 authenticate, version="+params.version+"\r\n");
    phidgets.client.write("report 8 report\r\n");
    phidgets.client.write("set /PCK/Client/0.0.0.0/1/PhidgetInterfaceKit=\"Open\" for session\r\n");
    phidgets.client.write("listen /PSK/PhidgetInterfaceKit lid0\r\n");

    if(typeof next == "function"){
      phidgets.checkReady(function(data) {
        next(null, data);
      });
    }
  });