note description: "[ Abstract implementation for all port read streams, used to read data from a port. ]" legal : "See notice at end of class." status : "See notice at end of class."; author : "Paul Bates (paul.a.bates@gmail.com)" date : "$Date$" revision: "$Revision$" deferred class PRT_STREAM_READER_I inherit PRT_STREAM feature -- Status report is_readable: BOOLEAN -- Indicates if the stream is readable. deferred end is_interface_usable: BOOLEAN -- do Result := is_readable ensure then is_readable: Result implies is_readable end feature -- Read operations frozen receive_8 (a_offset: NATURAL_8): NATURAL_8 -- Receives an 8-bit value to the port. -- Note: Check `is_successful' for a report if the last operation was read succesfully -- -- `a_offset': An port address offset. -- `Result': 8-bit data value to read from a port. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then Result := internal_receive_8 (port_address + a_offset) else determine_last_error if is_successful then -- No error code set last_error_code := -1 end end rescue retried := True retry end frozen receive_16 (a_offset: NATURAL_8): NATURAL_16 -- Receives an 16-bit value to the port. -- Note: Check `is_successful' for a report if the last operation was read succesfully -- -- `a_offset': An port address offset. -- `Result': 16-bit data value to read from a port. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then Result := internal_receive_16 (port_address + a_offset) else determine_last_error if is_successful then -- No error code set last_error_code := -1 end end rescue retried := True retry end frozen receive_32: NATURAL_32 -- Receives an 32-bit value to the port. -- Note: Check `is_successful' for a report if the last operation was read succesfully -- -- `Result': 32-bit data value to read from a port. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then Result := internal_receive_32 (port_address) else determine_last_error if is_successful then -- No error code set last_error_code := -1 end end rescue retried := True retry end feature {NONE} -- Read operations internal_receive_8 (a_address: NATURAL_16): NATURAL_8 -- Receives an 8-bit value from the port. -- -- `a_address': A port address to receive data from. -- `Result': 8-bit data value read from a port. require is_readable: is_readable deferred end internal_receive_16 (a_address: NATURAL_16): NATURAL_16 -- Reads an 16-bit value from the port. -- -- `a_address': A port address to receive data from. -- `Result': 16-bit data value read from a port. require is_readable: is_readable deferred end internal_receive_32 (a_address: NATURAL_16): NATURAL_32 -- Reads an 32-bit value from the port. -- -- `a_address': A port address to receive data from. -- `Result': 32-bit data value read from a port. require is_readable: is_readable deferred end end