User guide

46
VTB USER GUIDE
11 SYSTEM FUNCTIONS
VTB provides a wide LIBRERY to a complete management of the hardware devices. Some function can be available only
for some type of hardware
11.1 FUNCTIONS FOR THE SERIAL PORT CONTROL
All Promax hardware devices have 1 or 2 serial channel available to the application.
In VTB there are some object to manage the common serial protocol, for example MODBUS protocol both MASTER and
SLAVE. However it's possible to use one serial channel to customize the protocol.
To do that there are some API function which always refer to the SECOND SERIAL PORT of the hardware.
SER_SETBAUD
Programming the BaudRate of the second SERIALE PORT.
Hardware All
Syntax
SER_SETBAUD (long Baud)
Parameters
Baud Value of Baud Rate. The standard value are:
1200-2400-4800-9600-19200-38400-57600-115200
SER_MODE
Programming the mode of the second SERIAL PORT. If this function is never called, by default the port is programmed
with: No parity, 8 bits per character, 1 stop bit.
Hardware All
Syntax
SER_MODE(char par, char nbit, char nstop)
Parameters
par Parity (0=no parity, 1=odd parity, 2=even parity)
nbit Number of bits per character (7 or 8)
nstop Number of stop bits (1 or 2)
Example
ser_mode(1,8,2) Program the 2nd serial port with:
ODD-PARITY, 8 BIT/CHAR 2 STOP-BIT
SER_GETCHAR
Reads the receive buffer of the serial port. It doesn't wait for the presence of a character.
Hardware All
Syntax
SER_GETCHAR () as int
Return value:
-1 No character is in the buffer
>=0 Code of the character read from the buffer