|
12 | 12 | var EventEmitter = scope.EventEmitter, |
13 | 13 | TransportEvent = scope.TransportEvent, |
14 | 14 | Transport = scope.Transport, |
| 15 | + Logger = scope.Logger, |
15 | 16 | Pin = scope.Pin, |
16 | 17 | util = scope.util, |
17 | 18 | proto; |
|
94 | 95 | this._numDigitalPortReportRequests = 0; |
95 | 96 | this._transport = null; |
96 | 97 | this._pinStateEventCenter = new EventEmitter(); |
| 98 | + this._logger = new Logger('Board'); |
97 | 99 |
|
98 | 100 | this._initialVersionResultHandler = onInitialVersionResult.bind(this); |
99 | 101 | this._openHandler = onOpen.bind(this); |
|
126 | 128 |
|
127 | 129 | function onMessage(data) { |
128 | 130 | try { |
| 131 | + this._logger.info('onMessage', data); |
| 132 | + |
129 | 133 | var len = data.length; |
130 | 134 |
|
131 | 135 | if (len) { |
|
142 | 146 | } |
143 | 147 |
|
144 | 148 | function onError(error) { |
| 149 | + this._logger.warn('onError', error); |
145 | 150 | this._isReady = false; |
146 | 151 | this.emit(BoardEvent.ERROR, error); |
147 | 152 | setImmediate(this.disconnect.bind(this)); |
|
180 | 185 | } |
181 | 186 | } |
182 | 187 |
|
183 | | - function debug(msg) { |
184 | | - console && console.log(msg.stack || msg); |
185 | | - } |
186 | | - |
187 | 188 | Board.prototype = proto = Object.create(EventEmitter.prototype, { |
188 | 189 |
|
189 | 190 | constructor: { |
|
263 | 264 |
|
264 | 265 | switch (command) { |
265 | 266 | case DIGITAL_MESSAGE: |
| 267 | + this._logger.info('processMultiByteCommand digital:', channel, commandData[1], commandData[2]); |
266 | 268 | this.processDigitalMessage(channel, commandData[1], commandData[2]); |
267 | 269 | break; |
268 | 270 | case REPORT_VERSION: |
|
272 | 274 | }); |
273 | 275 | break; |
274 | 276 | case ANALOG_MESSAGE: |
| 277 | + this._logger.info('processMultiByteCommand analog:', channel, commandData[1], commandData[2]); |
275 | 278 | this.processAnalogMessage(channel, commandData[1], commandData[2]); |
276 | 279 | break; |
277 | 280 | } |
|
833 | 836 | resolution; |
834 | 837 |
|
835 | 838 | for (var i = 0; i < len; i++) { |
836 | | - debug('Pin ' + i + ':'); |
| 839 | + this._logger.info("reportCapabilities, Pin " + i); |
837 | 840 | for (var mode in capabilities[i]) { |
838 | 841 | if (capabilities[i].hasOwnProperty(mode)) { |
839 | 842 | resolution = capabilities[i][mode]; |
840 | | - debug('\t' + mode + ' (' + resolution + (resolution > 1 ? ' bits)' : ' bit)')); |
| 843 | + this._logger.info("reportCapabilities", '\t' + mode + ' (' + resolution + (resolution > 1 ? ' bits)' : ' bit)')); |
841 | 844 | } |
842 | 845 | } |
843 | 846 | } |
|
0 commit comments