EnttecUSBDMXPRO Driver Buffer API Fix (No Polyfill)

This commit is contained in:
Patrick Boyd 2018-07-09 17:55:05 -05:00
parent b7afca3ea2
commit 6dc9dddd52
2 changed files with 5 additions and 7 deletions

View file

@ -12,8 +12,7 @@ var ENTTEC_PRO_DMX_STARTCODE = 0x00
function EnttecUSBDMXPRO(device_id, options) { function EnttecUSBDMXPRO(device_id, options) {
var self = this var self = this
options = options || {} options = options || {}
this.universe = new Buffer(513) this.universe = Buffer.alloc(513, 0);
this.universe.fill(0)
this.dev = new SerialPort(device_id, { this.dev = new SerialPort(device_id, {
'baudRate': 250000, 'baudRate': 250000,
@ -31,7 +30,7 @@ EnttecUSBDMXPRO.prototype.send_universe = function() {
if(!this.dev.writable) { if(!this.dev.writable) {
return return
} }
var hdr = Buffer([ var hdr = Buffer.from([
ENTTEC_PRO_START_OF_MSG, ENTTEC_PRO_START_OF_MSG,
ENTTEC_PRO_SEND_DMX_RQ, ENTTEC_PRO_SEND_DMX_RQ,
(this.universe.length) & 0xff, (this.universe.length) & 0xff,
@ -42,7 +41,7 @@ EnttecUSBDMXPRO.prototype.send_universe = function() {
var msg = Buffer.concat([ var msg = Buffer.concat([
hdr, hdr,
this.universe.slice(1), this.universe.slice(1),
Buffer([ENTTEC_PRO_END_OF_MSG]) Buffer.from([ENTTEC_PRO_END_OF_MSG])
]) ])
this.dev.write(msg) this.dev.write(msg)
} }

View file

@ -3,8 +3,7 @@
function Null(device_id, options) { function Null(device_id, options) {
var self = this var self = this
options = options || {} options = options || {}
this.universe = new Buffer(513) this.universe = Buffer.alloc(513, 0);
this.universe.fill(0)
self.start() self.start()
} }
@ -40,4 +39,4 @@ Null.prototype.get = function(c) {
return this.universe[c] return this.universe[c]
} }
module.exports = Null module.exports = Null