| 2174 | }; |
| 2175 | |
| 2176 | void sectionPty(Runner& r, const QString& ptyPath) |
| 2177 | { |
| 2178 | r.section(QStringLiteral("Section 16 — PTY round-trip (skips if device cannot be opened)")); |
| 2179 | |
| 2180 | PtyClient p; |
| 2181 | if (!p.openDevice(ptyPath)) { |
| 2182 | const QString why = QStringLiteral("cannot open %1 (%2)") |
| 2183 | .arg(ptyPath, QString::fromLocal8Bit(::strerror(errno))); |
| 2184 | for (const char* name : { "16.1 get_freq via PTY", "16.2 get_mode via PTY", |
| 2185 | "16.3 get_info via PTY" }) |
| 2186 | r.skip(QString::fromLatin1(name), why); |
| 2187 | return; |
| 2188 | } |
| 2189 | |
| 2190 | QStringList lines = p.query(QStringLiteral("\\get_freq")); |
| 2191 | const QString freq = PtyClient::field(lines, QStringLiteral("Frequency")); |
| 2192 | r.check(QStringLiteral("16.1 get_freq via PTY → Frequency: <integer>"), |
| 2193 | PtyClient::ok(lines) && isInt(freq), |
| 2194 | freq.isEmpty() ? QStringLiteral("(no response)") : freq); |
| 2195 | |
| 2196 | lines = p.query(QStringLiteral("\\get_mode")); |
| 2197 | const QString mode = PtyClient::field(lines, QStringLiteral("Mode")); |
| 2198 | r.check(QStringLiteral("16.2 get_mode via PTY → Mode: <string>"), |
| 2199 | PtyClient::ok(lines) && !mode.isEmpty(), |
| 2200 | mode.isEmpty() ? QStringLiteral("(no response)") : mode); |
| 2201 | |
| 2202 | lines = p.query(QStringLiteral("\\get_rig_info")); |
| 2203 | const QString info = PtyClient::field(lines, QStringLiteral("Info")); |
| 2204 | r.check(QStringLiteral("16.3 get_rig_info via PTY → Info: <string>"), |
| 2205 | PtyClient::ok(lines) && !info.isEmpty(), |
| 2206 | info.isEmpty() ? QStringLiteral("(no response)") : info); |
| 2207 | } |
| 2208 | #else |
| 2209 | void sectionPty(Runner& r, const QString&) |
| 2210 | { |