-
-
Save reginaldojunior/64b962995fb9ef2b4143784e7b23698b to your computer and use it in GitHub Desktop.
Imprimindo com Bematech MP-4200 com node.js (sem cups nem módulos nativos)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
String.prototype.toBytes = function() { | |
var arr = [] | |
for (var i=0; i < this.length; i++) { | |
arr.push(this[i].charCodeAt(0)) | |
} | |
return arr; | |
} | |
var printData = "Hello World!".toBytes().concat([0x01B, 0x64, 10, 0x1d, 0x56, 0x00]); | |
var wstream = fs.createWriteStream('/dev/ttyACM0', { | |
encoding: 'utf16le' | |
}); | |
wstream.write(new Buffer(printData)); | |
wstream.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment