serForceDataReady (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


serForceDataReady will force that data is made ready (see serFrameReceiver) even if the criteria for a frame has not been met. This will set the "ready" output of the SerFrameReceiver function block to true immediately.

 

Note: this function will only work when operating in non-framed mode (eof=sof=0).

 

 

Input:

port : SINT (0..127) (default 0)

Selects which serial port to use.

 

Returns:

None.

 

Declaration:

FUNCTION serForceDataReady;
VAR_INPUT
  port : SINT := 0;   // Port number
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  RX       : serFrameReceiver;
  rxbuffer : ARRAY[0..5] of SINT; // Declare a buffer for receiving frames from the serial port
  portNum : SINT := 0;           // Select which port to use for the communication
  rx_dummy : SINT := 16#FF;
END_VAR;
 
// Open the serial port, set baudrate, parity and number of bits
serOpen(port:=portNum, baud:=9600, bit:=8, parity:=0);
// Enable receiving from the serial port, data will be stored in 'rxbuffer', start of frame is a <CR> and end of frame is a <LF>
RX(port:=portNum, enable:=TRUE, frame:=ADDR(rxbuffer), maxSize:=SIZEOF(rxbuffer));
 
// Set birst byte in buffer to Dummy
rxBuffer[0] := rx_dummy;
 
BEGIN
  // Allow the receive functionblock to be updated
  RX();
  // Check if a ModBus frame has been received
  IF rxBuffer[0] <> rx_dummy THEN
     // Frame received
    serForceDataReady(port:=portNum);
     ...
     // Release the buffer for the receiver as we are now finished with the received data
    serFrameReceiveDone(port:=portNum);
  END_IF;
END;
 
END_PROGRAM;