11 cout <<
"\n************************************************************************\n";
12 cout <<
"Example GCommand() usage\n";
13 cout <<
"************************************************************************\n";
19 cout <<
"Revision report, ^R^V\n";
20 x_e(
GCommand(g,
"\x12\x16", buf,
sizeof(buf), &read_bytes));
21 cout << buf <<
"\n\n";
28 cout <<
"Command Values\n";
32 cout <<
"val is " << vali <<
'\n';
34 sprintf(buf,
"val=%d", vali);
37 cout <<
"val is " << vali <<
'\n';
42 cout <<
"val is " << vald <<
'\n';
44 sprintf(buf,
"val=%f", vald);
47 cout <<
"val is " << vald <<
'\n';
50 cout <<
"\nCommand Trimming\n";
51 x_e(
GCommand(g,
"MGTIME", buf,
sizeof(buf), &read_bytes));
52 cout <<
">" << buf <<
"<" <<
'\n';
54 x_e(
GCmdT(g,
"MG TIME", buf,
sizeof(buf), 0));
55 cout <<
">" << buf <<
"<" <<
'\n';
58 x_e(
GCmdT(g,
"MG TIME", buf,
sizeof(buf), &front));
59 cout <<
">" << front <<
"<" <<
'\n';
62 cout <<
"\nReceiving Binary Data\n";
63 x_e(
GCommand(g,
"QR", buf,
sizeof(buf), &read_bytes));
64 cout <<
"QR read " << read_bytes <<
" bytes\n";
67 cout <<
"\nError handling\n";
70 cout <<
"QD correctly trapped, not allowed, try GArrayDownload()\n";
73 cout <<
"Unexpected QD behaviour\n";
74 return GALIL_EXAMPLE_ERROR;
78 cout <<
"DL correctly trapped, not allowed, try GProgramDownload()\n";
81 cout <<
"Unexpected DL behaviour\n";
82 return GALIL_EXAMPLE_ERROR;
86 cout <<
"\nModifying timeout\n";
88 cout <<
"Burning program...";
89 x_e(
GCommand(g,
"BP", buf,
sizeof(buf), &read_bytes));
93 return GALIL_EXAMPLE_OK;
GCLIB_DLL_EXPORTED GReturn GCALL GCmdT(GCon g, GCStringIn command, GCStringOut trimmed_response, GSize response_len, GCStringOut *front)
Wrapper around GCommand that trims the response.
GCLIB_DLL_EXPORTED GReturn GCALL GTimeout(GCon g, short timeout_ms)
Uses GUtility() and G_UTIL_TIMEOUT_OVERRIDE to set the library timeout.
GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
Performs a command-and-response transaction on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GCmdI(GCon g, GCStringIn command, int *value)
Wrapper around GCommand that provides the return value of a command parsed into an int.
GCLIB_DLL_EXPORTED GReturn GCALL GCmdD(GCon g, GCStringIn command, double *value)
Wrapper around GCommand that provides the return value of a command parsed into a double.
GCLIB_DLL_EXPORTED GReturn GCALL GCmd(GCon g, GCStringIn command)
Wrapper around GCommand for use when the return value is not desired.
#define G_COMMAND_CALLED_WITH_ILLEGAL_COMMAND
GCommand() was called with an illegal command, e.g. ED, DL or QD.
int GReturn
Every function returns a value of type GReturn. See gclib_errors.h for possible values.
#define G_NO_ERROR
Return value if function succeeded.
unsigned int GSize
Size of buffers, etc.
#define G_USE_INITIAL_TIMEOUT
GUtility(), for timeout override. Set G_UTIL_TIMEOUT_OVERRIDE to this value to use initial GOpen() ti...
void * GCon
Connection handle. Unique for each connection in process. Assigned a non-zero value in GOpen().
void x_e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
int x_gcommand(GCon g)
Example GCommand() usage.