beautypg.com

Solvline PB2xxxUG User Manual

Page 87

background image

unsigned char port_no;

// 1 ~ 16

int

speed;

// 0=150 ~ 11=230400 BPS

char

lcr;

// data bits + parity bits + stop bits

char

flow;

// 0=None, 1=Xon/Xoff, 2=RTS/CTS

short

sock_no;

// My socket No.

unsigned char dest_ip [20]; // destination IP

unsigned short dest_port;

// destination socket No.

short

mtu;

// 1 ~ 1100

char

signal;

// 0=Dataonly, 1=Modem

short

alive_time;

// 0 ~ 32767

};

/*---------------------------------------------------------------*/

/* System's configuration is to determine these arguments. */

/*---------------------------------------------------------------*/

int main (int argc, char *argv[])

/*---------------------------------------------------------------*/

{

struct SYS_INFO

SYS;

int SFD;

// Serial Device FD

int LFD;

// socket FD

char WORK [1024];

int ret;

printf ("\nStart User Application\n");

SYS.port_no

=

atoi

(argv[1]);

SYS.speed

=

atoi

(argv[2]);

SYS.lcr

=

atoi

(argv[3]);

SYS.flow =

atoi

(argv[4]);

SYS.sock_no

=

atoi

(argv[5]);

strcpy

(SYS.dest_ip, argv[6]);

SYS.dest_port

=

atoi

(argv[7]);

SYS.mtu

=

atoi

(argv[8]);

SYS.alive_time = atoi (argv[9]);

SYS.signal

=

atoi

(argv[10]);

printf ("No=%d,Speed=%d,lcr=%d,flow=%d,My socket=%d,

Dest IP=%s(%d),MTU=%d,Alive=%d,Signal=%d\n",

SYS.port_no, SYS.speed, SYS.lcr, SYS.flow, SYS.sock_no,

SYS.dest_ip, SYS.dest_port, SYS.mtu, SYS.alive_time, SYS.signal);

SFD = U_open_port (SYS.port_no);

// Open serial port

U_init_port (SFD, SYS.speed, SYS.lcr, SYS.flow);

// Setting serial port

printf ("Check Serial Type = %d (0=232, 1=422, 2=485)\n",

U_check_type (SFD));

// get type

printf ("Check DCD signal = %d (0=OFF, 1=ON)\n",

U_check_dcd (SFD));

// get signal

printf ("H/W MAC address = ");

U_get_mac (WORK);

// get MAC address

for (ret=0; ret<6; ret++) printf ("%02x:", WORK[ret]);

printf ("\n");

LFD = U_listen (SYS.sock_no);

if (LFD == -1)

{

87