Skip to content

Instantly share code, notes, and snippets.

@renatoargh
Created August 29, 2016 02:57
Show Gist options
  • Select an option

  • Save renatoargh/7baec3926d93bf4a0d5876fc7aef334c to your computer and use it in GitHub Desktop.

Select an option

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();
@renatoargh

renatoargh commented Oct 7, 2020 via email

Copy link
Copy Markdown
Author

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