RTS_CONTROL (ENUM) ¶ TYPE RTS_CONTROL : Configuration for RTS control (see parameter udiRtsControl) Attributes: qualified_only InOut: Name Initial Comment RTS_CONTROL_DISABLE 0 0 = Disables the RTS line RTS_CONTROL_ENABLE 1 = Enables the RTS line RTS_CONTROL_HANDSHAKE 2 = Enables RTS handshaking RTS_CONTROL_TOGGLE 3 = Specifies that the RTS line will be high if bytes are available for transmission. After all buffered bytes have been sent, the RTS line will be low.
STOPBIT (ENUM) ¶ TYPE STOPBIT : Supported number of stop bits Attributes: qualified_only InOut: Name Initial Comment ONESTOPBIT 0 0 = 1 stopbit ONE5STOPBITS 1 = 1.5 stopbits TWOSTOPBITS 2 = 2 stopbits
Function Blocks ¶ Close (FunctionBlock) Open (FunctionBlock) Read (FunctionBlock) Write (FunctionBlock)
Close (FB) ¶ FUNCTION_BLOCK Close EXTENDS CBM.ETrig Close a serial com port opened via the FB COM. Open . The output handle hCom must be used here to close the COM port! InOut: Scope Name Type Comment Input hCom CAA.HANDLE Handle to the open COM port. Ist returned by the COM. Open function block. Output eError ERROR Local library error ID (0: no error; 5001: time out)
Open (FB) ¶ FUNCTION_BLOCK Open EXTENDS CBM.ETrig Open a serial com port. The input Parameter s are a list of settings, with which the COM port should be opened. Example: COMPort = 1, Baudrate = 115200, Parity = None, StopBit s = 1 DECLARATION: MyComOpen : COM.Open ; aParamsB115200 : ARRAY [1..7] OF COM.PARAMETER := [ (udiParameterId := COM.CAA_Parameter_Constants.udiPort, udiValue := 1), (udiParameterId := COM.CAA_Parameter_Constants.udiBaudrate, udiValue := 115200), (udiParameterId := COM.CAA_Parameter_Constants.udiParity, udiValue := COM.PARITY.NONE), (udiParameterId := COM.CAA_Parameter_Constants.udiStopBits, udiValue := COM.STOPBIT.ONESTOPBIT), (udiParameterId := COM.CAA_Parameter_Constants.udiTimeout, udiValue := 0), (udiParameterId := COM.CAA_Parameter_Constants.udiByteSize, udiValue := 8), (udiParameterId := COM.CAA_Parameter_Constants.udiBinary, udiValue := 1) ] ; IMPLEMENTATION: So to parameterize the FB looks like: MyComOpen ( usiListLength := SIZEOF ( aParamsB115200 )/ SIZEOF ( COM.PARAMETER ), pParameterList := ADR ( aParamsB115200 )); ... InOut: Scope Name Type Comment Input usiListLength USINT Number of entries in the pParameterList pParameterList CAA.PVOID Pointer to ARRAY of parameter entries Output eError ERROR Local library error ID (0: no error; 5001: time out) hCom CAA.HANDLE specific Outputs
Read (FB) ¶ FUNCTION_BLOCK Read EXTENDS CBM.ETrigToA Function block to read data from the serial port InOut: Scope Name Type Comment Input hCom CAA.HANDLE Handle to the open COM port. Ist returned by the COM. Open function block. pBuffer CAA.PVOID Pointer to a buffer to get the received data from the COM port szBuffer CAA.SIZE Maximum size of the pBuffer parameter in bytes Output eError ERROR Local library error ID (0: no error; 5001: time out) szSize CAA.SIZE Returns the number of received data bytes in pBuffer
Write (FB) ¶ FUNCTION_BLOCK Write EXTENDS CBM.ETrigToA Function block to write data to the serial port InOut: Scope Name Type Comment Input hCom CAA.HANDLE Handle to the open COM port. Ist returned by the COM. Open function block. pBuffer CAA.PVOID Pointer to a buffer with the data to write to the COM port szSize CAA.SIZE Number of bytes in pBuffer to write to the COM port Output eError ERROR Local library error ID (0: no error; 5001: time out)
Global Variables ¶ CAA_Parameter_Constants (GVL)
CAA_Parameter_Constants (GVL) ¶ Parameter IDs for the PARAMETER struct. InOut: Scope Name Type Initial Comment Constant udiPort UDINT 16#1 DataType=INT | Port number parameter udiStopBits UDINT 16#2 DataType=BYTE | Stop bits parameter. See STOPBIT for possible parameter values. udiParity UDINT 16#3 DataType=BYTE | Parity parameter. See PARITY for possible parameter values. udiBaudrate UDINT 16#4 DataType=DWORD | Baudrate parameter udiTimeout UDINT 16#5 DataType=UDINT | Timeout parameter udiBufferSize UDINT 16#6 DataType=UDINT | Buffer size parameter, sets the serial buffer size udiByteSize UDINT 16#7 DataType=BYTE | Byte size parameter, it sets the number of data bits 4-8 udiBinary UDINT 16#8 DataType=BOOL | Binary parameter, enables the binary mode udiOutxCtsFlow UDINT 16#9 DataType=BOOL | CTS handshaking on output parameter udiOutxDsrFlow UDINT 16#A DataType=BOOL | DSR handshaking on output parameter udiDtrControl UDINT 16#B DataType=BYTE | DTR Flow control parameter. See DTR_CONTROL for possible parameter values. udiDsrSensitivity UDINT 16#C DataType=BOOL | DSR Sensitivity parameter udiRtsControl UDINT 16#D DataType=BYTE | Rts Flow control parameter. See RTS_CONTROL for possible parameter values. udiTXContinueOnXoff UDINT 16#E DataType=BOOL | XOFF continues Tx parameter udiOutX UDINT 16#F DataType=BOOL | XON/XOFF out flow control parameter udiInX UDINT 16#10 DataType=BOOL | XON/XOFF in flow control parameter udiXonChar UDINT 16#11 DataType=BYTE | Tx AND Rx XON character parameter udiXoffChar UDINT 16#12 DataType=BYTE | Tx AND Rx XOFF character parameter udiXonLim UDINT 16#13 DataType=WORD | Transmit XON threshold parameter udiXoffLim UDINT 16#14 DataType=WORD | Transmit XOFF threshold parameter
Structs ¶ PARAMETER (Struct)