本文整理汇总了C++中Port::FullWriteString方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::FullWriteString方法的具体用法?C++ Port::FullWriteString怎么用?C++ Port::FullWriteString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::FullWriteString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: args
int
main(int argc, char **argv)
{
Args args(argc, argv, "PORT BAUD");
const DeviceConfig config = ParsePortArgs(args);
args.ExpectEnd();
InitialiseIOThread();
MyHandler handler;
Port *port = OpenPort(config, handler);
if (port == NULL) {
fprintf(stderr, "Failed to open COM port\n");
return EXIT_FAILURE;
}
ConsoleOperationEnvironment env;
if (!port->WaitConnected(env)) {
delete port;
DeinitialiseIOThread();
fprintf(stderr, "Failed to connect the port\n");
return EXIT_FAILURE;
}
if (!port->StartRxThread()) {
delete port;
DeinitialiseIOThread();
fprintf(stderr, "Failed to start the port thread\n");
return EXIT_FAILURE;
}
char stamp[6] = "";
char line[1024];
while (fgets(line, sizeof(line), stdin) != NULL) {
if (memcmp(line, "$GP", 3) == 0 &&
(memcmp(line + 3, "GGA", 3) == 0 ||
memcmp(line + 3, "RMC", 3) == 0) &&
line[6] == ',' &&
strncmp(stamp, line + 7, sizeof(stamp)) != 0) {
/* the time stamp has changed - sleep for one second */
Sleep(1000);
strncpy(stamp, line + 7, sizeof(stamp));
}
if (!port->FullWriteString(line, env, 1000)) {
fprintf(stderr, "Failed to write to port\n");
delete port;
return EXIT_FAILURE;
}
}
delete port;
DeinitialiseIOThread();
return EXIT_SUCCESS;
}
示例2: CleanString
/**
* Clean a string and write it to the Port.
*/
static bool
WriteCleanString(Port &port, const TCHAR *p,
OperationEnvironment &env, unsigned timeout_ms)
{
NarrowString<256> buffer;
buffer.SetASCII(p);
CleanString(buffer.buffer());
return port.FullWriteString(buffer, env, timeout_ms);
}
示例3: CopyString
/**
* Clean a string and write it to the Port.
*/
static bool
WriteCleanString(Port &port, const TCHAR *p, unsigned timeout_ms)
{
char buffer[256];
#ifdef _UNICODE
if (::WideCharToMultiByte(CP_ACP, 0, p, -1, buffer, sizeof(buffer),
NULL, NULL) <= 0)
return false;
#else
CopyString(buffer, p, sizeof(buffer));
#endif
CleanString(buffer);
return port.FullWriteString(buffer, timeout_ms);
}
示例4: sprintf
static bool
WriteGeoPoint(Port &port, const GeoPoint &value, OperationEnvironment &env)
{
int DegLat, DegLon;
double tmp, MinLat, MinLon;
TCHAR NoS, EoW;
// prepare latitude
tmp = (double)value.latitude.Degrees();
NoS = _T('N');
if (tmp < 0)
{
NoS = _T('S');
tmp = -tmp;
}
DegLat = (int)tmp;
MinLat = (tmp - DegLat) * 60 * 1000;
// prepare long
tmp = (double)value.longitude.Degrees();
EoW = _T('E');
if (tmp < 0)
{
EoW = _T('W');
tmp = -tmp;
}
DegLon = (int)tmp;
MinLon = (tmp - DegLon) * 60 * 1000;
char buffer[64];
sprintf(buffer, "%02d%05d%c%03d%05d%c",
DegLat, (int)MinLat, NoS,
DegLon, (int)MinLon, EoW);
return port.FullWriteString(buffer, env, 1000);
}
示例5: assert
static bool
DeclareInner(Port &port, const Declaration &declaration,
OperationEnvironment &env)
{
assert(declaration.Size() >= 2);
assert(declaration.Size() <= 12);
char user_data[2500];
if (!TryConnectRetry(port, user_data, sizeof(user_data), env))
return false;
char *p = strstr(user_data, "USER DETAILS");
if (p != NULL)
*p = 0;
port.Write('\x18'); // start to upload file
if (!port.FullWriteString(user_data, env, 5000) ||
!port.FullWriteString("USER DETAILS\r\n--------------\r\n\r\n",
env, 1000))
return false;
WritePair(port, "Pilot Name", declaration.pilot_name.c_str(), env);
WritePair(port, "Competition ID", declaration.competition_id.c_str(), env);
WritePair(port, "Aircraft Type", declaration.aircraft_type.c_str(), env);
WritePair(port, "Aircraft ID",
declaration.aircraft_registration.c_str(), env);
if (!port.FullWriteString("\r\nFLIGHT DECLARATION\r\n-------------------\r\n\r\n",
env, 1000))
return false;
WritePair(port, "Description", _T("XCSoar task declaration"), env);
for (unsigned i = 0; i < 11; i++) {
if (env.IsCancelled())
return false;
if (i+1>= declaration.Size()) {
port.FullWriteString("TP LatLon: 0000000N00000000E TURN POINT\r\n",
env, 1000);
} else {
const Waypoint &wp = declaration.GetWaypoint(i);
if (i == 0) {
if (!EWMicroRecorderWriteWaypoint(port, "Take Off LatLong", wp, env) ||
!EWMicroRecorderWriteWaypoint(port, "Start LatLon", wp, env))
return false;
} else if (i + 1 < declaration.Size()) {
if (!EWMicroRecorderWriteWaypoint(port, "TP LatLon", wp, env))
return false;
}
}
}
const Waypoint &wp = declaration.GetLastWaypoint();
if (!EWMicroRecorderWriteWaypoint(port, "Finish LatLon", wp, env) ||
!EWMicroRecorderWriteWaypoint(port, "Land LatLon", wp, env) ||
env.IsCancelled())
return false;
port.Write('\x03'); // finish sending user file
return port.ExpectString("uploaded successfully", env, 5000);
}
示例6:
static bool
WriteLabel(Port &port, const char *name, OperationEnvironment &env)
{
return port.FullWriteString(name, env, 1000) &&
port.FullWrite(": ", 2, env, 500);
}
示例7:
static bool
WriteLabel(Port &port, const char *name)
{
return port.FullWriteString(name, 1000) &&
port.FullWrite(": ", 2, 500);
}