1var uart = require('uart'); 2 3var msgbuf = 'this is amp uart test' 4// led灯 5var serial = uart.open({ 6 id: 'serial', 7 success: function() { 8 console.log('open spi success') 9 }, 10 fail: function() { 11 console.log('open spi failed') 12 } 13}); 14 15serial.write(msgbuf) 16var value = serial.read() 17 18console.log('sensor value is ' + value) 19 20serial.on('data', function(len, data) { 21 console.log('uart receive data len is : ' + len + ' data is: ' + data); 22}) 23 24serial.close();