//Create a client object connected to the server
XmlRpcClient xmlrpc = new XmlRpcClient(“http://192.168.1.51/RPC2”);
// Build the gpib.Send() parameters list
Vector params = new Vector();
params.addElement(new Integer(2)); //GPIB primary address
params.addElement(“CH1:SCALE?”.getBytes()); //String to send (in //binary format)
params.addElement(new Integer(1)); //Termination value
//Make the Send remote procedure call
xmlrpc.execute(“gpib.Send”, params);
//Build the gpib.Receive() parameters list
Vector params = new Vector();
params.addElement(new Integer(2)); //GPIB primary address
params.addElement(new Integer(500)); //Receive a maximum of 500 bytes
params.addElement(new Integer(1)); //Termination value
//Make the Receive remote procedure call and store the response
Hashtable response =
(Hashtable) xmlrpc.execute(“gpib.Receive”, params);
//Receive returns the query response in a hash table with the key “buffer.”
//Extract the binary-formatted answer and store it in a byte array.
byte[] buffer = (byte[]) response.get(“buffer”);
//Convert the answer back to an ASCII string. This will be the V/div
//setting of channel one in floating point (e.g., 100E-3 for 100 mV).
String str = new String(buffer, “US-ASCII”);
Listing 3—In this GPIB RPC
query sequence, the client sends a query asking the oscilloscope for its channel
one vertical scale settings with an XML-RPC gpib.Send() call. Following this,
the output is retrieved with a gpib.Receive() call and then parsed.