Skip to content

Instantly share code, notes, and snippets.

@renatoargh
Created August 29, 2016 02:57
Show Gist options
  • Save renatoargh/7baec3926d93bf4a0d5876fc7aef334c to your computer and use it in GitHub Desktop.
Save renatoargh/7baec3926d93bf4a0d5876fc7aef334c to your computer and use it in GitHub Desktop.
Imprimindo com Bematech MP-4200 com node.js (sem cups nem módulos nativos)
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();
@Patrique
Copy link

Patrique commented Oct 6, 2020

@renatoargh no windows basta eu inserir COM01 no createwritestream? estou tentando e nada, estou fazendo algo de errado ou em windows não rola?

@renatoargh
Copy link
Author

renatoargh commented Oct 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment