@@ -2496,7 +2496,7 @@ Paho.MQTT = (function (global) {
24962496} ) ( window ) ;
24972497
24982498var webduino = webduino || {
2499- version : '0.5.0 '
2499+ version : '0.5.1 '
25002500} ;
25012501
25022502if ( typeof exports !== 'undefined' ) {
@@ -4172,18 +4172,13 @@ if (typeof exports !== 'undefined') {
41724172 }
41734173
41744174 function cleanup ( ) {
4175- this . disconnect ( function ( ) {
4176- if ( typeof exports !== 'undefined' ) {
4177- process . exit ( ) ;
4178- }
4179- } ) ;
4175+ this . disconnect ( ) ;
41804176 }
41814177
41824178 function attachCleanup ( self ) {
41834179 if ( typeof exports === 'undefined' ) {
41844180 window . addEventListener ( 'beforeunload' , self . _cleanupHandler ) ;
41854181 } else {
4186- process . addListener ( 'SIGINT' , self . _cleanupHandler ) ;
41874182 process . addListener ( 'uncaughtException' , self . _cleanupHandler ) ;
41884183 }
41894184 }
@@ -4192,7 +4187,6 @@ if (typeof exports !== 'undefined') {
41924187 if ( typeof exports === 'undefined' ) {
41934188 window . removeEventListener ( 'beforeunload' , self . _cleanupHandler ) ;
41944189 } else {
4195- process . removeListener ( 'SIGINT' , self . _cleanupHandler ) ;
41964190 process . removeListener ( 'uncaughtException' , self . _cleanupHandler ) ;
41974191 }
41984192 }
@@ -4474,7 +4468,6 @@ if (typeof exports !== 'undefined') {
44744468 }
44754469
44764470 if ( ! this . _isReady ) {
4477- this . systemReset ( ) ;
44784471 this . enableDigitalPins ( ) ;
44794472 }
44804473 } ;
@@ -4568,20 +4561,26 @@ if (typeof exports !== 'undefined') {
45684561 } ;
45694562
45704563 proto . sendDigitalData = function ( pin , value ) {
4571- var portNum = Math . floor ( pin / 8 ) ;
4572-
4573- if ( value === Pin . HIGH ) {
4574- // Set the bit
4575- this . _digitalPort [ portNum ] |= ( value << ( pin % 8 ) ) ;
4576- } else if ( value === Pin . LOW ) {
4577- // Clear the bit
4578- this . _digitalPort [ portNum ] &= ~ ( 1 << ( pin % 8 ) ) ;
4579- } else {
4580- // Should not happen...
4581- throw new Error ( 'Invalid value passed to sendDigital, value must be 0 or 1.' ) ;
4582- }
4564+ try {
4565+ var portNum = Math . floor ( pin / 8 ) ;
4566+
4567+ if ( value === Pin . HIGH ) {
4568+ // Set the bit
4569+ this . _digitalPort [ portNum ] |= ( value << ( pin % 8 ) ) ;
4570+ } else if ( value === Pin . LOW ) {
4571+ // Clear the bit
4572+ this . _digitalPort [ portNum ] &= ~ ( 1 << ( pin % 8 ) ) ;
4573+ } else {
4574+ // Should not happen...
4575+ throw new Error ( 'Invalid value passed to sendDigital, value must be 0 or 1.' ) ;
4576+ }
45834577
4584- this . sendDigitalPort ( portNum , this . _digitalPort [ portNum ] ) ;
4578+ this . sendDigitalPort ( portNum , this . _digitalPort [ portNum ] ) ;
4579+ } catch ( err ) {
4580+ console . error ( 'Board -> sendDigitalData, msg:' , err . message , 'value:' , value ) ;
4581+ this . emit ( BoardEvent . ERROR , err ) ;
4582+ setImmediate ( this . disconnect . bind ( this ) ) ;
4583+ }
45854584 } ;
45864585
45874586 proto . sendServoData = function ( pin , value ) {
0 commit comments