10#include <gtest/gtest.h>
14using namespace testing;
20 static IEEE4888_TEST_INSTRUMENT_CLASS *
pInstrument;
46 ASSERT_EQ(
true, pInstrument->Write (
"*IDN?"));
48 ASSERT_EQ(
true, pInstrument->Read (l_Buffer));
56 ASSERT_EQ(
true, pInstrument->Write (std::string(
"*IDN?")));
58 ASSERT_EQ(
true, pInstrument->Read (l_Buffer));
66 const char * l_Command =
"*IDN?";
67 CSCPIBuffer l_CmdBuffer(l_Command, std::strlen(l_Command));
68 ASSERT_EQ(
true, pInstrument->Write (l_CmdBuffer));
70 ASSERT_EQ(
true, pInstrument->Read (l_Buffer));
79 ASSERT_EQ(
true, pInstrument->Write (
"*IDN?"));
81 ASSERT_EQ(
true, pInstrument->Read (l_Buffer,
false));
85 ASSERT_EQ(
true, pInstrument->ReadSTB (l_Status));
86 if ((l_Status & 0x0010) == 0)
break;
87 ASSERT_EQ(
true, pInstrument->Read (l_Buffer,
true));
99 ASSERT_EQ(
false, pInstrument->Read (l_Buffer));
100 ASSERT_EQ(
true, pInstrument->Timeout());
103 ASSERT_EQ(
true, pInstrument->Write (
"*IDN?"));
104 ASSERT_EQ(
false, pInstrument->Timeout());
105 ASSERT_EQ(
true, pInstrument->Read (l_Buffer));
106 ASSERT_EQ(
false, pInstrument->Timeout());
115 std::string l_LongCommand;
116 for (
int i = 0; i < 1000; i++)
117 l_LongCommand +=
"*SRE 0;";
118 U32 l_Timeout = pInstrument->GetTimeout();
119 pInstrument->SetTimeout(1ul);
120 ASSERT_EQ(
false, pInstrument->Write (l_LongCommand));
121 ASSERT_EQ(
true, pInstrument->Timeout());
124 pInstrument->SetTimeout(l_Timeout);
125 ASSERT_EQ(
true, pInstrument->Write (
"*IDN?"));
126 ASSERT_EQ(
false, pInstrument->Timeout());
128 ASSERT_EQ(
true, pInstrument->Read (l_Buffer));
129 ASSERT_EQ(
false, pInstrument->Timeout());
TEST_F(IEEE488InstrumentReadWriteTest, IDN_Query_WriteCString)
Test *IDN? query with C string variant of Write.
bool ConnectToIEEE488Instrument(IEEE4888_TEST_RESOURCE_MANAGER_CLASS *&rpResourceManager, IEEE4888_TEST_INSTRUMENT_CLASS *&rpInstrument)
Connect to an IEEE488Instrument.
bool CheckIDNResponse(const CSCPIBuffer &rBuffer)
Sanity-check of the response to an *IDN? query.
Utility functions used to test IEEE488Instrument API.
unsigned int U32
32-bit unsigned integer.
unsigned short U16
16-bit unsigned integer.
static void TearDownTestCase()
static IEEE4888_TEST_INSTRUMENT_CLASS * pInstrument
static IEEE4888_TEST_RESOURCE_MANAGER_CLASS * pResourceManager
static void SetUpTestCase()