-
Notifications
You must be signed in to change notification settings - Fork 7
/
machine-connection.h
28 lines (23 loc) · 1.09 KB
/
machine-connection.h
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
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
* (c) [email protected]. Free Software. GNU Public License v3.0 and above
*/
#ifndef MACHINE_CONN_H
#define MACHINE_CONN_H
// Open a connection to a machine. The "descriptor" is a string describing
// the connection to the machine. This can be different ways to connect to
// a machine.
// Supported formats
// - terminal: path, optional speed "/dev/ttyUSB0,b115200"
// - "hostname:port" (in fact: not yet supported, but needed for BeagleG)
//
// Returns a bi-directional file-descriptor or -1 if opening failed.
int OpenMachineConnection(const char *descriptor);
// While there is stuff readable on the file-descriptor, discard the input
// until there is silence on the wire for "timeout_ms". Helps to get into
// a clean state. Returns number of bytes discarded.
int DiscardPendingInput(int fd, int timeout_ms);
// For for "ok" string that 3D printers use as 'flow control'. It is important
// to wait for this ack after each command sent to he printer otherwise
// commands might get lost.
void WaitForOkAck(int fd);
#endif // MACHINE_CONN_H