File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 3030 DISCONNECT : 'disconnect'
3131 } ;
3232
33- // Message command bytes (128-255/0x80-0xFF)
33+ /**
34+ * Message command bytes (128-255/0x80-0xFF)
35+ * https://github.com/firmata/protocol/blob/master/protocol.md
36+ */
3437 var DIGITAL_MESSAGE = 0x90 ,
3538 ANALOG_MESSAGE = 0xE0 ,
3639 REPORT_ANALOG = 0xC0 ,
122125 }
123126
124127 function onMessage ( data ) {
125- var len = data . length ;
128+ try {
129+ var len = data . length ;
126130
127- if ( len ) {
128- for ( var i = 0 ; i < len ; i ++ ) {
129- this . processInput ( data [ i ] ) ;
131+ if ( len ) {
132+ for ( var i = 0 ; i < len ; i ++ ) {
133+ this . processInput ( data [ i ] ) ;
134+ }
135+ } else {
136+ this . processInput ( data ) ;
130137 }
131- } else {
132- this . processInput ( data ) ;
138+ } catch ( err ) {
139+ console . error ( err ) ;
140+ throw err ;
133141 }
134142 }
135143
You can’t perform that action at this time.
0 commit comments