bool EWMicroRecorderDevice::Declare(const Declaration *decl) { // Must have at least two, max 12 waypoints if (decl->size() < 2 || decl->size() > 12) return false; port->StopRxThread(); port->SetRxTimeout(500); // set RX timeout to 500[ms] if (!TryConnect()) return false; port->Write('\x18'); // start to upload file port->Write(user_data); EWMicroRecorderPrintf(port, _T("%-15s %s\r\n"), _T("Pilot Name:"), decl->PilotName); EWMicroRecorderPrintf(port, _T("%-15s %s\r\n"), _T("Competition ID:"), decl->AircraftRego); EWMicroRecorderPrintf(port, _T("%-15s %s\r\n"), _T("Aircraft Type:"), decl->AircraftType); port->Write("Description: Declaration\r\n"); for (unsigned i = 0; i < 11; i++) { if (i+1>= decl->size()) { EWMicroRecorderPrintf(port, _T("%-17s %s\r\n"), _T("TP LatLon:"), _T("0000000N00000000E TURN POINT\r\n")); } else { const Waypoint &wp = decl->waypoints[i]; if (i == 0) { EWMicroRecorderWriteWayPoint(port, wp, _T("Take Off LatLong:")); EWMicroRecorderWriteWayPoint(port, wp, _T("Start LatLon:")); } else if (i + 1 < decl->size()) { EWMicroRecorderWriteWayPoint(port, wp, _T("TP LatLon:")); } } } const Waypoint &wp = decl->waypoints[decl->size() - 1]; EWMicroRecorderWriteWayPoint(port, wp, _T("Finish LatLon:")); EWMicroRecorderWriteWayPoint(port, wp, _T("Land LatLon:")); port->Write('\x03'); // finish sending user file bool success = ExpectStringWait(port, "uploaded successfully"); port->Write("!!\r\n"); // go back to NMEA mode port->SetRxTimeout(0); // clear timeout port->StartRxThread(); // restart RX thread return success; }
bool LX::CommandMode(Port &port, OperationEnvironment &env) { /* switch to command mode, first attempt */ port.Write(SYN); /* now flush all of the remaining input */ port.SetRxTimeout(10); port.FullFlush(20); /* the port is clean now; try the SYN/ACK procedure up to three times */ return port.SetRxTimeout(500) && (Connect(port, env) || Connect(port, env) || Connect(port, env)) && /* ... and configure the timeout */ port.SetRxTimeout(5000); }
bool AltairProDevice::Declare(const struct Declaration &declaration, OperationEnvironment &env) { port->SetRxTimeout(500); // set RX timeout to 500[ms] bool result = DeclareInternal(declaration); return result; }
bool EWDevice::Declare(const struct Declaration *decl, OperationEnvironment &env) { port->StopRxThread(); lLastBaudrate = port->SetBaudrate(9600L); // change to IO Mode baudrate port->SetRxTimeout(500); // set RX timeout to 500[ms] bool success = DeclareInner(decl, env); port->Write("NMEA\r\n"); // switch to NMEA mode port->SetBaudrate(lLastBaudrate); // restore baudrate port->SetRxTimeout(0); // clear timeout port->StartRxThread(); // restart RX thread return success; }
bool EWMicroRecorderDevice::Declare(const Declaration &declaration, OperationEnvironment &env) { // Must have at least two, max 12 waypoints if (declaration.size() < 2 || declaration.size() > 12) return false; /* during tests, the EW has taken up to one second to respond to the command \x18 */ port->SetRxTimeout(2500); bool success = DeclareInner(*port, declaration, env); port->Write("!!\r\n"); // go back to NMEA mode return success; }
static bool DeclareInner(Port &port, const Declaration &declaration, gcc_unused OperationEnvironment &env) { using CAI302::UploadShort; unsigned size = declaration.Size(); port.SetRxTimeout(500); env.SetProgressRange(6 + size); env.SetProgressPosition(0); CAI302::CommandModeQuick(port); if (!CAI302::UploadMode(port) || env.IsCancelled()) return false; port.SetRxTimeout(1500); CAI302::PilotMeta pilot_meta; if (!CAI302::UploadPilotMeta(port, pilot_meta) || env.IsCancelled()) return false; env.SetProgressPosition(1); CAI302::Pilot pilot; if (!CAI302::UploadPilot(port, 0, pilot) || env.IsCancelled()) return false; env.SetProgressPosition(2); CAI302::PolarMeta polar_meta; if (!CAI302::UploadPolarMeta(port, polar_meta) || env.IsCancelled()) return false; env.SetProgressPosition(3); CAI302::Polar polar; if (!CAI302::UploadPolar(port, polar) || env.IsCancelled()) return false; env.SetProgressPosition(4); if (!CAI302::DownloadMode(port) || env.IsCancelled()) return false; char GliderType[13], GliderID[13]; convert_string(GliderType, sizeof(GliderType), declaration.aircraft_type); convert_string(GliderID, sizeof(GliderID), declaration.aircraft_registration); convert_string(pilot.name, sizeof(pilot.name), declaration.pilot_name); if (!CAI302::DownloadPilot(port, pilot) || env.IsCancelled()) return false; env.SetProgressPosition(5); convert_string(polar.glider_type, sizeof(polar.glider_type), declaration.aircraft_type); convert_string(polar.glider_id, sizeof(polar.glider_id), declaration.aircraft_registration); if (!CAI302::DownloadPolar(port, polar) || env.IsCancelled()) return false; env.SetProgressPosition(6); for (unsigned i = 0; i < size; ++i) { if (!cai302DeclAddWaypoint(port, i, declaration.GetWaypoint(i)) || env.IsCancelled()) return false; env.SetProgressPosition(7 + i); } port.SetRxTimeout(1500); // D,255 takes more than 800ms return CAI302::DeclareSave(port); }