6 F 3 B 0 3 6 2

 

 

sprintf( &csnd[

strlen( csnd ) ], "%02d", idat ) ;

sprintf( &csnd[

strlen( csnd) ], "," ) ;

 

icunt = 0

;

 

/* Comparison data storage index. */

for( j = 0,

k =

0; k < DATASIZ; k++ ){

/* Set register write data. */

sprintf( &csnd[ strlen( csnd) ], "%04X", k ) ;

j = j

+

4 ;

 

 

sprintf( &csnd[ strlen( csnd) ], "," ) ;

j = j

+

1 ;

 

 

icunt

=

icunt + 4 ;

 

}

 

 

 

 

sprintf( &csnd[

(strlen( csnd )) - 1], ")¥r" ) ;

isndsiz =

strlen( csnd );

/* Set the send data length.

*/

 

 

 

 

Snd.sin_family = AF_INET;

Snd.sin_addr.s_addr = inet_addr( DST_IP ); /* Set the remote IP address.

*/

 

 

 

 

 

Snd.sin_port = htons( DST_PORT );

 

 

/* Set the remote port number.

*/

 

 

 

 

 

 

 

 

/* Send a register write request.

*/

 

 

 

 

 

ists = sendto( Isdp, csnd, isndsiz,

0,

 

 

 

(struct sockaddr *)&Snd,sizeof( Snd ) );

 

 

if ( ists == isndsiz ){

/*

If the send length was OK. */

 

/*

Set the SELECT argument.

*/

memset(&ibits,0x00,sizeof(fd_set));

/* Set the BIT initial value. */

timeout.tv_sec = RECVTOUT;

/*

Set the timeout time. */

 

FD_SET(Isdp,&ibits);

/*

BIT setup

*/

 

ists = select( 1, &ibits,0,0,(struct timeval *)&timeout);

 

if(ists > 0){

/*

If normal return:

*/

 

 

/*

Register write response reception */

ists = recvfrom( Isdp, crcv,

sizeof( crcv ), 0

 

 

,(struct sockaddr *)&Rcv, &ircvsiz) ;

 

 

if ( ists > 5 ){

 

 

 

 

 

if( crcv[ 4 ] == 'C' && crcv[ 5 ] == 'E'

 

 

crcv[ 4 ] == 'E' && crcv[ 5 ] == 'E' ){

 

 

return( -1 ) ;

/*

Register write response error */

}

 

 

 

 

 

/* Register read request creation */

memset( csnd, 0x00, sizeof( csnd ) ) ; memset( crcv, 0x00, sizeof( crcv ) ) ;

sprintf( &csnd[ 0 ] , "(A01DR" );/* Register read command setup

*/

/* Set up the starting reg. no.

*/

sprintf( &csnd[ strlen(csnd)], "%s", REG_TYPE ); sprintf( &csnd[ strlen(csnd) ], "%04s", REG_ADR ); sprintf( &csnd[ strlen( csnd) ], "," ) ;

55

Page 56
Image 56
Toshiba T2N instruction manual ⎯ 55 ⎯