note description: "[ Abstract implementation for all port writer streams, used to send data to 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_WRITER_I inherit PRT_STREAM feature -- Query is_writable: BOOLEAN -- Indicates if the stream is writable. deferred end is_interface_usable: BOOLEAN -- do Result := is_writable ensure then is_writable: Result implies is_writable end feature -- Write operations frozen send_8 (a_data: NATURAL_8; a_offset: NATURAL_8) -- Sends an 8-bit value to the port. -- -- `a_data': 8-bit data value to send to a port. -- `a_offset': An port address offset. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then internal_send_8 (port_address + a_offset, a_data) else determine_last_error if is_successful then -- No error code set last_error_code := -1 end end rescue retried := True retry end frozen send_16 (a_data: NATURAL_16; a_offset: NATURAL_8) -- Sends an 16-bit value to the port. -- -- `a_data': 16-bit data value to send to a port. -- `a_offset': An port address offset. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then internal_send_16 (port_address + a_offset, a_data) else determine_last_error if is_successful then -- No error code set last_error_code := -1 end end rescue retried := True retry end frozen send_32 (a_data: NATURAL_32) -- Sends an 32-bit value to the port. -- -- `a_data': 32-bit data value to send to a port. require is_interface_usable: is_interface_usable local retried: BOOLEAN do if not retried then internal_send_32 (port_address, a_data) 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} -- Write operations internal_send_8 (a_address: NATURAL_16; a_data: NATURAL_8) -- Sends an 8-bit value to the port. -- -- `a_address': A port address to send the data to. -- `a_data': 8-bit data value to send to a port. require is_writable: is_writable deferred end internal_send_16 (a_address: NATURAL_16; a_data: NATURAL_16) -- Sends an 16-bit value to the port. -- -- `a_address': A port address to send the data to. -- `a_data': 16-bit data value to send to a port. require is_writable: is_writable deferred end internal_send_32 (a_address: NATURAL_16; a_data: NATURAL_32) -- Sends an 32-bit value to the port. -- -- `a_address': A port address to send the data to. -- `a_data': 32-bit data value to send to a port. require is_writable: is_writable deferred end end