RTC6 boards
Doc. Rev. 1.0.21 en-US
10 RTC6 Commands
595
Ctrl Command rs232_read_data
Function Reads a value from the input buffer of the RS-232 interface, see Chapter 9.2.3
”RS-232 Interface”, page 288.
Call
RS232Data = rs232_read_data()
Result As an unsigned 32-bit value.
Bit #0
(LSB)
…
Bit #7
Next (not yet read by the user program) value of the input buffer.
Bit #8 “New” bit:
= 1: The value is new (has not been previously read).
= 0: The value is old (has been already read once
by rs232_read_data).
Bit #9
…
Bit #15
0.
Bit #16
…
Bit #23
Number of further (not yet read) characters.
Bit #24
…
Bit #31
Number of buffer overruns.
Comments • The RS-232 interface is internally is read in internally asynchronously (one character at
a time). If this character is new, then it is stored in a 256-character ring buffer. From
there, it can be transferred to the user program by rs232_read_data (asynchronously
to reading).
• Byte #0 (Bit #0…Bit #7) returns only one character from the current reading position.
• Byte #1 (Bit #8) indicates if the character has already been read by the user program.
• Byte #2 (Bit #16…Bit #23) indicates the number of characters in the input buffer that
still have not been read by the user program. If no unread characters are present
(byte #2 = 0), then the most recently read character is transferred with “new bit” = 0.
• Byte #3 (Bit #24…Bit #31) indicates the number of overruns of the input buffer (a
corresponding number of characters were overwritten and therefore irretrievably lost).
Important: To reset the overflow counter, you must call rs232_read_data
correspondingly often!
• Example: return value 459098 = 0x0007015A = (0, 7, 1, 90) means:
character 90 ('Z') has been read and is new (1), 7 additional characters remain to be
read, the buffer has been never overrun (0).