--
--	Inmos Libraries
--	Copyright (C) 1988, 1989, 1990, 1991, 1993  Inmos Limited
--
--	This library is free software; you can redistribute it and/or
--	modify it under the terms of the GNU Lesser General Public
--	License as published by the Free Software Foundation; either
--	version 2 of the License, or (at your option) any later version.
--
--	This library is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--	Lesser General Public License for more details.
--
--	You should have received a copy of the GNU Lesser General Public
--	License along with this library; if not, write to the Free Software
--	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
--

--** @module hostio

#COMMENT "Host i/o library, V1.00, 10/03/89"
#COMMENT "(c) Copyright INMOS Limited 1989"
#INCLUDE "hostio.inc"
--{{{  sp.send.packet
--* Send an SP protocol packet.
--
-- @param ts the channel on which to send the packet
-- @param packet the packet to send
-- @param error FALSE if the packet size is greater than or equal to
--   sp.min.packet.data.size, and is less than or equal to
--   sp.max.packet.data.size, and is even; TRUE otherwise, in which
--   case the packet is not sent
PROC sp.send.packet (CHAN OF SP ts, VAL []BYTE packet, BOOL error)
  IF
    ((SIZE packet) < sp.min.packet.data.size) OR
    ((SIZE packet) > sp.max.packet.data.size) OR
    (((SIZE packet) /\ 1) <> 0)  -- check that the packet length is EVEN
      error := TRUE
    TRUE
      SEQ
        ts ! INT16 (SIZE packet) :: packet
        error := FALSE
:
--}}}sp.send.packet
--{{{  sp.receive.packet
--* Receive an SP protocol packet.
--
-- @param fs the channel on which to receive the packet
-- @param length the number of bytes in the received packet
-- @param packet the received packet, left justified
-- @param error TRUE if length is greater than sp.max.packet.data.size;
--   FALSE otherwise
PROC sp.receive.packet (CHAN OF SP fs, INT16 length, []BYTE packet, BOOL error)
  SEQ
    fs ? length :: packet
    error := ((INT length) > sp.max.packet.data.size)
:
--}}}sp.receive.packet
