blob: 758a63607ed9570385a1fdf9839379e51260a36e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package octoprintApis
import (
"bytes"
"encoding/json"
// "fmt"
// "io"
// "strings"
// "github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
)
// CommandRequest sends any command to the printer via the serial interface.
// Should be used with some care as some commands can interfere with or even
// stop a running print job.
type CommandRequest struct {
// Commands list of commands to send to the printer.
Commands []string `json:"commands"`
}
// Do sends an API request and returns an error if any.
func (cmd *CommandRequest) Do(c *Client) error {
b := bytes.NewBuffer(nil)
if err := json.NewEncoder(b).Encode(cmd); err != nil {
return err
}
_, err := c.doJsonRequest("POST", PrinterCommandApiUri, b, nil)
return err
}
|