Skip to content

Commit

Permalink
ScpiClient: add calibration date query
Browse files Browse the repository at this point in the history
  • Loading branch information
willeccles committed May 13, 2024
1 parent f608bb9 commit 58e5c96
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/bci/abs/ScpiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ScpiClient {

Result<std::uint8_t> GetDeviceId() const;

Result<std::string> GetCalibrationDate() const;

Result<int> GetErrorCount() const;

Result<ScpiError> GetNextError() const;
Expand Down
4 changes: 4 additions & 0 deletions src/ScpiClient_System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Result<std::uint8_t> ScpiClient::GetDeviceId() const {
.and_then(scpi::ParseIntResponse<std::uint8_t>);
}

Result<std::string> ScpiClient::GetCalibrationDate() const {
return SendAndRecv("CAL:DATE?\r\n").and_then(scpi::ParseStringResponse);
}

Result<int> ScpiClient::GetErrorCount() const {
return SendAndRecv("SYST:ERR:COUN?\r\n")
.and_then(scpi::ParseIntResponse<int>);
Expand Down
9 changes: 9 additions & 0 deletions src/ScpiUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ std::optional<std::string> ParseQuotedString(std::string_view str) {
return ret;
}

Result<std::string> ParseStringResponse(std::string_view str) {
auto e = ParseQuotedString(util::Trim(str));
if (e) {
return *std::move(e);
} else {
return Err(ec::kInvalidResponse);
}
}

Result<ScpiError> ParseScpiError(std::string_view str) {
str = util::Trim(str);

Expand Down
2 changes: 2 additions & 0 deletions src/ScpiUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ constexpr Result<std::array<CellMode, kLen>> ParseCellOperatingModeArray(
// Parse quoted SCPI <String> data.
std::optional<std::string> ParseQuotedString(std::string_view str);

Result<std::string> ParseStringResponse(std::string_view str);

Result<ScpiError> ParseScpiError(std::string_view str);

} // namespace bci::abs::scpi
Expand Down

0 comments on commit 58e5c96

Please sign in to comment.