Communication Port
Communication
 
Image bm1059.GIF open port (-1=error)
 
The open port element opens the port carrying the entered name and sets this port active. As the element parameter the name of the port or the name of the communication device is entered. For serial ports these are the COM1, COM2 etc. names. The element returns the identification number serving to select the active port. Several ports may be opened at a time. By means of the identification number the active port may be selected that we want to work with, without the transfer through the other ports being interrupted. When an opening error occurs (wrong port name, or the port is used by another program), the element will return -1, otherwise a number >= 0 is returned.
 
Image bm1060.GIF close port
 
The close port command closes the port, the identification number of which is specified as an element parameter. After closing a port this port may be used by other programs. After finishing a program all ports are closed automatically.
 
Image bm1061.GIF active port
 
The active port command determines the active port, with which further operations will be carried out. As a parameter the identification number is entered that has been returned when opening the port. The identification number is an internal pointer in the open port table only. By changing the active port the performance of any of the ports is not influenced.
 
Image bm1062.GIF baud rate
 
The baud rate element defines the transfer rate of a serial port in Baud. For a standard COM port following transfer rate values are permitted:
 
110 Baud
150 Baud
300 Baud
600 Baud
1200 Baud
2400 Baud
4800 Baud
9600 Baud
14400 Baud
19200 Baud
28800 Baud
38400 Baud
56000 Baud (only some types of COM)
57600 Baud
115200 Baud
128000 Baud (only some types of COM)
256000 Baud (only some types of COM)
 
Image bm1063.GIF 2 stop bits
 
The 2 stop bits element is a logic flag defining, whether the transfer protocol will use 2 stop bits (or 1.5 bits for the character length of 5 bits). When the flag is reset, 1 stop bit will be used.
 
Image bm1064.GIF number of bits (5 to 8)
 
The number of bits element defines the number of bits for one character. Permitted values are 5, 6, 7 and 8 bits. For characters 5 or 6 bits long the characters received (if received as a text; this is not valid for receiving as a number) are transferred to printable characters by adding the value of 64 (i.e. the 0 character is changed to "@", the 1 character is changed to "A" etc.). When sending, the redundant bits will be ignored. So, for example, the bit number being 5, the "A" character will change to 1.
 
Image bm1065.GIF parity (0=none, 1=odd, 2=even, 3=mark, 4=space)
 
The parity element defines the way of checking the data transferred by the supplementary parity bit. If a character is transferred in a wrong way (incorrect parity), it is replaced by the highest valid character (for 8 bits the number 255, for 7 bits the number 127, for 6 bits the number 63, for 5 bits the number 31). Following values are permitted:
 
0 = none parity
1 = odd parity
2 = even parity
3 = mark parity
4 = space parity
 
Image bm1066.GIF character was received
 
The character was received element is a logic flag indicating, whether the received character is ready.
 
Image bm1067.GIF sending is allowed (CTS, RTS)
 
The sending is allowed element is a flag indicating the value of control signals for the send request. The data transfer is not influenced by this signal. It depends on the program, how this signal will be utilized. By writing the logic value into this element the state of the control signal RTS is influenced (normally used as a request for the counterpart to send). By reading the element the state of the control signal CTS may be detected (used as the counterpart request input to send).
 
Image bm1068.GIF receiving is allowed (DSR, DTR)
 
The receiving is allowed element is a flag indicating the value of control signals for the receive request. The data transfer is not influenced by this signal. It depends on the program, how this signal will be utilized. By writing the logic value into this element the state of the control signal DTR is influenced (normally used as a counterpart information about its own readiness or as a validity confirmation of data sent to the counterpart). By reading the element the state of the control signal DSR may be detected (used as the counterpart readiness confirmation input or as a validity confirmation of data sent by the counterpart).
 
Image bm1069.GIF number
 
The number element is a numeric value serving to send and receive a character in form of a numeric code. By entering a number into the element the character will be sent to the counterpart. During sending the character the program is stopped, but for maximum 0.1 seconds. The character numeric value may range between 0 and the maximum value, according to the number of bits per character (255 for 8 bits, 127 for 7 bits, 63 for 6 bits, 31 for 5 bits). Values outside this range are rounded into a proper range by the modulo operation. By reading the element value the character is received. The reception takes place on the background while the program is running. By means of the character was received element it can be tested, whether the character received is ready. When the character is not ready, the element will be waiting for the character reception, but for maximum 0.1 seconds. If no character has been received, the element will return 0. If the character checking by means of parity is switched on, and if a transfer error occurs, a character corresponding to the last valid character (255 for 8 bits, 127 for 7 bits, 63 for 6 bits, 31 for 5 bits) will be returned.
 
Image bm1070.GIF character (text)
 
The character (text) element is a text variable serving to send and receive a character (or, as the case may be, a text). By entering a character (or even a longer text) into this element the character (text) will be sent to the counterpart. During sending the character the program is stopped, but for maximum 0.1 seconds for each character. The character numeric value may range between 1 and the maximum value, according to the number of bits per character (255 for 8 bits, 127 for 7 bits, 63 for 6 bits, 31 for 5 bits). Values outside this range are rounded into a proper range by the modulo operation. By reading the element value one character (not the text) is received. For 5 and 6 bits the characters are transferred to displayable characters by adding 64 to the character code (i.e. the characters "@", "A", etc.). The reception takes place on the background while the program is running. By means of the character was received element it can be tested, whether the character received is ready. When the character is not ready, the element will be waiting for the character reception, but for maximum 0.1 seconds. If no character has been received, the element will return an empty text (the same way as when receiving a 0 code character, when 7 or 8 bits are concerned). If the character checking by means of parity is switched on, and if a transfer error occurs, a character corresponding to the last valid character (255 for 8 bits, 127 for 7 bits and 6 bits, 63 for 5 bits) will be returned.

Full Html Context Help of The Peter - Gemtree Software & Children Programming