EtherSpaceLink-RG408
EtherSpaceLink family User Manual
14.4. Gett
i
n
g S
t
ar
te
d
-
a
n
i
n
i
t
ia
l e
xa
mple
A
P
I
p
r
o
gra
m
A
s
i
m
pl
e e
x
a
m
pl
e
p
r
o
gr
a
m
i
s
p
r
esented
h
e
r
e.
/**************************************************************************/
/* (c) May 2013,
R M A Peel, 4Links Limited
*/
/* */
/* Send one SpaceWire packet to a loopback connection on port 1 of an
*/
/* EtherSpaceLink-family unit, then listen for a response packet (also
*/
/* from port 1).
*/
/* */
/* Requires a loopback connector on port 1
*/
/* */
/* Run as
*/
/* c-api-example1-esl <IP address of ESL> <input filename>
*/
/* */
/* Compile on Linux:
*/
/* gcc -O2 -o c-api-example1-esl c-api-example1-esl.c EtherSpaceLink.c
*/
/* -lm -lpthread */
/* */
/* Compile on Windows:
*/
/* cl /MT /D "_X86_" c-api-example1-esl.c EtherSpaceLink.c wsock32.lib
*/
/* */
/**************************************************************************/
#include "EtherSpaceLink.h"
#include <stdio.h>
int main ( int argc, char * argv [] )
{
EtherSpaceLink ESL_unit;
// pointer to our ESL
char rx_buffer [4096]; // receive buffer
int bytes_received;
// the size of the packet returned
int terminator;
// the native interface terminator
int loop_index, status; // misc storage
unsigned char
HWA [6];
// Ethernet hardware address
if ( argc != 2 )
{ fprintf ( stderr, "Usage: %s <IP-address>\n", argv[0] );
exit (1);
}
ESL_unit = EtherSpaceLink_open ( argv[1] );
if ( ESL_unit == 0 )
{ fprintf ( stderr, "Unable to open connection to %s\n", argv[1] );
exit (1);
}
/* Get static ESL product information */
printf ( "%s ",
EtherSpaceLink_get_manufacturer_string ( ESL_unit ) );
printf ( "%s ",
EtherSpaceLink_get_product_string ( ESL_unit ) );
printf ( "(%i ports)\n", EtherSpaceLink_get_number_of_links ( ESL_unit ) );
EtherSpaceLink_get_HWA ( ESL_unit, HWA );
printf ( "Serial number %s ",
EtherSpaceLink_HWA_to_serial_number_string ( HWA ) );
printf ( "at %2.2X-%2.2X-%2.2X-%2.2X-%2.2X-%2.2X \n\n",
HWA[0], HWA[1], HWA[2], HWA[3], HWA[4], HWA[5] );
4Links Limited
www.4Links.co.uk
[email protected]
page 41 of 110
T +44 1908 642001; F +44 1908 363463
Milton Keynes MK3 6EB, UK
Suite EU2, Bletchley Park