Open (FB)
FUNCTION_BLOCK Open EXTENDS CBM.ETrig
Open a serial com port.
The input Parameters are a list of settings, with which the COM port should be opened.
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
Inherited from
Input
xExecuteBOOLRising edge: Action startsFalling edge: Resets outputsIf a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone,xError) are present at the outputs for exactly one cycle.ETrig
Output
xDoneBOOLTRUE: Action successfully completedETrig
xBusyBOOLTRUE: Function block activeETrig
xErrorBOOLTRUE: Error occurred, function block aborts actionFALSE: No errorETrig
Input
usiListLengthUSINTNumber of entries in the pParameterList
pParameterListCAA.PVOIDPointer to ARRAY of parameter entries
Output
eErrorLocal library error ID (0: no error; 5001: time out)
hComCAA.HANDLEspecific Outputs