-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcode.cpp
57 lines (44 loc) · 1.16 KB
/
testcode.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//-*-mode:c++; mode:font-lock;-*-
#include<DataStream.hpp>
#include<VSDataConverter.hpp>
#include"ESPProtocol.hpp"
using namespace VERITAS;
using namespace VTracking;
using namespace VMessaging;
using namespace MotionControl;
int main(int argc, char** argv)
{
const char* program = *argv;
argv++,argc--;
if(argc!=1)
{
std::cerr << "Usage: " << program << " position" << '\n';
exit(EXIT_FAILURE);
}
const char* port = "/dev/ttyUSB0";
ESPProtocol::IAxis iaxis = 2;
ESPProtocol::Dist z = 0;
VSDataConverter::fromString(z,*argv);
argv++,argc--;
DataStream* ds = 0;
try
{
ds = ESPProtocol::makeSerialDataStream(port);
ESPProtocol esp(ds);
esp.clearAllErrorCodes();
esp.progBeginDownload(0);
esp.cmdStopMotion(iaxis);
esp.progFinishDownload();
esp.setAssignDIOToExecuteStoredProgram(0, 0);
esp.cmdMoveToAbsolutePosition(iaxis,z);
esp.pollForMotionDone(iaxis);
esp.getActualPosition(iaxis, z);
std::cerr << z << std::endl;
}
catch(const CommunicationError& x)
{
x.print(std::cerr);
std::cerr << strerror(x.errorNum()) << '\n';
}
delete ds;
}