Generic ASCII Data Exchange

The following illustrations show the different data exchanges using the serial module.

Data Sent with the Serial Port

Data is sent out of the serial port using the following steps:
  1. The controller sends out the consumed packet with an incremented
    TxID
    (consume tag).
  2. The serial module puts the packet into the TxBuffer (Transmit Buffer).
  3. The serial module takes the oldest data from the TxBuffer and sends it out to the target.
Data Sent Out to the Serial Port

Generic ASCII Transmit Methods

In Generic ASCII mode, you can define any kind of data to be transmitted to communicate to serial devices. Some examples are barcode scanners, dial-up modems, serial printers, temperature controllers, and so on.
To transmit the ASCII packet based on the number of characters, follow these steps:
  1. Set the Termination Mode to Ignore End Delimiter.
  2. After copying the characters into the
    ASCII.TxData
    output tag array, write the number of characters into the
    ASCII.TxDataLength
    output tag, then increment the
    ASCII.TxID
    output tag.
To transmit the ASCII packet based on the Termination Delimiter characters, follow these steps:
  1. Set the Termination Mode to Include or Exclude.
    TIP:
    Include mode transmits the packet with Termination Delimiter characters, and Exclude mode does not.
  2. After copying the characters into the
    ASCII.TxData
    output tag array, copy the two configured Termination Delimiter characters as the next two characters in the array, then increment the
    ASCII.TxID
    output tag. While doing this, keep the
    TxDataLength
    output tag at 0.

Data Received from Serial Port in Immediate Mode

After the serial port receives data, it processes the data using the following steps:
  1. The serial module receives the packet.
  2. If any of the following conditions occur, the serial module creates a record:
    • Message Timeout timer expires.
    • The number of received bytes equals the configured Read Buffer Size.
    • Termination Delimiter bytes were received.
  3. The serial module copies the data into the
    ASCII.RxData
    input tag, copies the number of characters that are received into the
    ASCII.RxDataLength
    input tag, increments the
    ASCII.RxID
    input tag and sends it to the controller.
    TIP: The
    ASCII.RxDataError
    input tag is set if the data copied to the
    ASCII.RxData
    input tag contains an error (that is, parity error or framing error).
Data Received from the Serial Port in Immediate Mode

Data Received from Serial Port in Master/Slave Handshake Mode

The serial port works in a handshake mode using the following steps:
  1. The serial module receives the packet.
  2. If any of the following conditions occur, the serial module creates a record:
    • The Message Timeout timer expires
    • The number of received bytes equals the configured Read Buffer Size
    • Termination Delimiter bytes were received.
  3. The record is added into the RxBuffer (Receive Buffer).
  4. Once the RxID (Consume Tag) is incremented by the user logic, the serial module takes the oldest record from RxBuffer, copies the data into the
    ASCII.RxData
    input tag, copies the number of characters received into the
    ASCII.RxDataLength
    input tag, and sends it to the controller.
Data Received from Serial Port in Master/Slave Handshake Mode
IMPORTANT:
If Master/Slave Handshake is selected, dispose additional receiving data from the serial port for saved data in the receiving buffer of the firmware.

Generic ASCII Receive Methods

When receiving the ASCII packet based on the fixed number of characters:
  • Set the Termination Mode to Ignore End Delimiter.
  • Set the number of characters in bytes using the Read Buffer Size.
When receiving the ASCII packet based on a timeout since the last character was received:
  • Set the Termination Mode to Ignore End Delimiter.
  • Set the Message Timeout to the desired timeout value in milliseconds.
When receiving the ASCII packet based on Termination Delimiters at the end of the packet:
  • Set the Termination Mode to Include or Exclude.
    If the Termination Mode is “Include”, then the termination bytes remain appended to the end of the data copied into the
    ASCII.RxData
    input tag. If the Termination Mode is “Exclude”, then the termination bytes are stripped off.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal