beautypg.com

Write_com, Usb_open, Usb_close – Argox PA-20 Programming Guide User Manual

Page 94

background image

PT-20 Programming Guide

92

i = read_com(1,c);

if (i) _printf(“char %c received from COM1”,*c);

Includes:

#include “SDK.h ”

Description: This routine is used to read one byte from the receive buffer and then

remove it from the buffer. However, if the buffer is empty, no action is taken

and 0 is returned.

Use the argument “port” as the connect port which is

chosen to open. You can choose 1(RS232).

Returns: 1, available or 0 if buffer is empty

write_com

Purpose: Send a string out through RS232 port

Syntax: int write_com(int port, char *s);

Example call:

char s[20]={“Hello World\n”};

write_com(1,s);

Includes:

#include “SDK.h ”

Description: This routine is used to send a string through RS232 ports. If any prior

transmission is still in process, it is terminated then the current transmission

resumes. The character string is transmitted one by one until a NULL

character is met. A null string can be used to terminate prior transmission.

Use the argument “port” as the connect port which is chosen to open. You

can choose 1(RS232).

If you select RS-232 and set hardware flow control(CTS/RTS), this function

will wait while data be transmitted.

Returns: -1 : error

Other value: the number of words that success writing into.

USB_Open

Purpose: Initialize and enable USB port.

Syntax: void USB_Open(void);

Example call: USB_Open();

Includes:

#include “SDK.h ”

Description: The USB_Open function initializes and enable USB port.

Returns: None

USB_Close

Purpose: To close USB port

Syntax: void USB_Close(void);

Example call: USB_Close();

Includes:

#include “SDK.h ”

Description: The USB_Close function disable and suspend USB port.

Returns: None