Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhorner committed Sep 6, 2017
2 parents 7bea2c3 + 921c2c3 commit 41dfbf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const JsonRpc = require('./lib/jsonrpc')
const fs = require('fs')
const crc = require('crc')
const Reflector = require('makerbot')
const path = require('path')

// Client ID/secret, for LAN access
const AUTH_CLIENT_ID = "MakerWare"
Expand Down Expand Up @@ -275,11 +276,14 @@ class MakerbotRpcClient extends EventEmitter {
}

printFile(file) {
// TODO what's the max length of the file name?
var filename = path.parse(file).base

// TODO handle errors in this promise
return new Promise((resolve, reject) => {
fs.readFile(file, (err, data) => {
this.client.request("print", {
filepath: "print.makerbot",
filepath: filename,
transfer_wait: true
})
.then(res => {
Expand All @@ -290,10 +294,11 @@ class MakerbotRpcClient extends EventEmitter {
this.client.request("process_method", {
method: "build_plate_cleared"
})

return this.client.request("put_init", {
block_size: data.length,
file_id: "1",
file_path: "/current_thing/print.makerbot",
file_path: `/current_thing/${filename}`,
length: data.length
})
})
Expand Down

0 comments on commit 41dfbf1

Please sign in to comment.