english
version "1.0"
identify "xyz"

#: Copyright (c) 2005 by Wayne C. Gramlich.
#, All rights reserved.

#: This module provides an interface to the Unix terminal I/O system.

module serial_port

define serial_port				#: Terminal I/O block
    external


procedure byte_read@serial_port
    takes
	serial_port serial_port
	block logical
    returns unsigned
    external serial_port__byte_read

    #: This procedure will read in a byte from {serial_port}.  If {block}
    #, is {true}@{logical}, the call will block until the byte is
    #, available; otherwise, 0xffffffff is returned if no byte is
    #, available.



procedure byte_write@serial_port
    takes
	serial_port serial_port
	byte unsigned
	flush logical
    returns unsigned
    external serial_port__byte_read

    #: This procedure will write {byte} to {serial_port}.  If {flush}
    #, is {true}@{logical}, {byte} will be immediately flushed out;
    #, otherwise, {byte} may be buffered in memory for a while.



procedure close@serial_port
    takes
	serial_port serial_port
    returns_nothing
    external serial_port__close

    #: This procedure will close {serial_port}.



procedure drain@serial_port
    takes
	serial_port serial_port
    returns_nothing

    #: This procedure will read in and ignore all available input
    #, on {serial_port}.


procedure error_number_get@serial_port
    takes
	serial_port serial_port
    returns unsigned
    external serail_port__error_number_get

    #: This procedure will return the error number associated with
    #, {serial_port}.



procedure flush@serial_port
    takes
	serial_port serial_port
    returns_nothing
    external termial__flush

    #: This procedure will flush out all buffered data in {serial_port}.



procedure identical@serial_port
    takes
	serial_port1 serial_port
	serial_port2 serial_port
    returns logical
    external serial_port__identical

    #: This procedure will return {true}@{logical} if {serial_port1} is
    #, identical to {serial_port2}.



procedure open@serial_port
    takes
	path string
	buad_rate unsigned
    returns serial_port
    external serial_port__open

    #: This prodedure open a connection to {path} with baud rate of {baud_rate}
    #, return the ssociated {serial_port} object.



procedure print@serial_port
    takes
	serial_port serial_port
	out_stream out_stream
    returns_nothing

    #: This procedure will print {serial_port} to {out_stream}.