Agilent Technologies N5183A Portable Generator User Manual


 
116 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming Examples
LAN Programming Interface Examples
/*********************************************************
* Send command to signal generator
*********************************************************/
command_err = commandInstrument(sock, command);
if (command_err) return COMMAND_ERROR;
/*********************************************************
* Read response from signal generator
********************************************************/
count = recv(sock, tmp_buf, 1, 0); /* read 1 char */
ch = tmp_buf[0];
if ((count < 1) || (ch == EOF) || (ch == '\n'))
{
*result = '\0'; /* null terminate result for ascii */
return 0;
}
/* use a do-while so we can break out */
do
{
if (ch == '#')
{
/* binary data encountered - figure out what it is */
long numDigits;
long numBytes = 0;
/* char length[10]; */
count = recv(sock, tmp_buf, 1, 0); /* read 1 char */
ch = tmp_buf[0];
if ((count < 1) || (ch == EOF)) break; /* End of file */
if (ch < '0' || ch > '9') break; /* unexpected char */
numDigits = ch - '0';
if (numDigits)
{
/* read numDigits bytes into result string. */
count = recv(sock, result, (int)numDigits, 0);
result[count] = 0; /* null terminate */