Datasat AP25 Installation And Operating Manual page 168

Table of Contents

Advertisement

/* ======================================================================== **
*
Prototypes
* ======================================================================== */
int AP20Command( char *strAp20_IpAddress, char *StrCmd, char *StrPassword );
int Send( int fd , char *StrCmd );
int ReadResponse( int fd , char *StrCmd );
/* ======================================================================== **
*
Functions
* ======================================================================== */
/* ------------------------------------------------------------------------ **
*
Function:
main
*
*
Picks up the Command from the command line arguments.
*
In this example the AP20 IP address and AP20 Setup password is hardcoded.
* ------------------------------------------------------------------------ */
int main (int argc, char **argv)
{
char StrCmd[256];
int cnt;
if ( argc < 2)
{
printf ("Usage: Ap20NetCmd arg1 ... arg\n");
exit(1);
}
// collect args
int firstarg=1;
snprintf( StrCmd, sizeof(StrCmd), "%s", argv[firstarg++] );
for ( cnt = firstarg; cnt < argc; cnt++ )
{
strcat ( StrCmd , " ");
strcat ( StrCmd , argv[cnt]);
}
AP20Command( StrAp20Ip, StrCmd, StrAp20Password );
}
/* ------------------------------------------------------------------------ **
*
Function:
AP20Command
*
*
- A socket connection to the AP20 is established to the AP20 IP
*
address using port 14500.
*
- Send the AUTH command if the AP20 has a password defined.
* ------------------------------------------------------------------------ */
int AP20Command( char *strAp20_IpAddress, char *StrCmd, char *StrPassword )
{
int fd;
struct sockaddr_in MySocket;
memset(&MySocket, 0, sizeof(MySocket));
MySocket.sin_addr.s_addr = inet_addr( "127.0.0.1" );
MySocket.sin_addr.s_addr = inet_addr( strAp20_IpAddress );
MySocket.sin_family
MySocket.sin_port
// Get a file descriptor for the socket
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("socket() failed\n");
return -1;
}
// Connect to the AP20
if( ::connect( fd, (struct sockaddr *)&MySocket, sizeof( MySocket ) ) != 0 )
Appendix H. Serial Command AP!
AP25 Installation and Operating Guide
// sender main socket
= AF_INET;
= htons( AP20_PORT_NUM );
// Set the AP20 IP address here
// Set the AP20 Port address
H-12
Document #: 9301H79500 Ver. 1.00
Version 1.00

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AP25 and is the answer not in the manual?

Questions and answers

Table of Contents