Programming Examples

This section contains several sample functions written in C, (and one in Visual Basic) that can be used as references when programming Anritsu Handheld Products. These include functions to set up the comm port, enter and exit remote mode, and set the reference level of the spectrum analyzer.

Examples in C

/*********************************************************************/

/*

unsigned char EnterRemote(BYTE *ResponseBytes)

*/

/*

Description: This function implements control byte #69, Enter

*/

/*

 

Remote Mode. If successful, the unit will be in

*/

/*

 

remote mode, waiting to accept additional serial

*/

/*

 

commands.

*/

/*

Inputs :

ResponseBytes = pointer to an array of bytes at

*/

/*

 

least 13 elements long (13 bytes are expected in

*/

/*

 

response to the Enter Remote command).

*/

/*

Returns:

SUCCESS if the unit is in remote mode

*/

/*

 

FAILURE if the command fails

*/

/*

 

Response bytes are returned in the variable

*/

/*

 

ResponseBytes.

*/

/*********************************************************************/

unsigned char EnterRemote(BYTE *ResponseBytes)

 

{

 

 

 

 

BYTE *SendEnterRemoteCharPointer; // Data to send

 

 

BYTE SerialCommand;

 

 

SendEnterRemoteCharPointer = &SerialCommand;

 

 

SerialCommand = 69; // 69 is the Enter Remote Mode serial command

 

// Write 1 byte of data from SendEnterRemoteCharPointer to the

// COM Port

 

WriteToPort

(SendEnterRemoteCharPointer, 1);

 

//Read the data returned by the SiteMaster - expecting 13 bytes,

//give the unit 30 seconds to respond before timing out. if(!ReadFromPort(13, ResponseBytes, 30))

{

return FAILURE;

}

else

{

return SUCCESS;

}

}/* EnterRemote */

108

Site Master PM

Page 114
Image 114
Anritsu S331D, S332D manual Examples in C, Site Master PM