From: Otto Tuil <tuil@dds.nl>
Newsgroups: comp.sys.transputer
Subject: Re: C - Occam communication
Date: Thu, 11 Mar 1999 13:37:06 +0100
Organization: Ericsson
Message-Id: <36E7B8F2.80E52791@dds.nl>
References: <01be6ba7$f82901a0$0600000a@peter.ross.IMSDOM>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Xref: ukc comp.sys.transputer:9086


Peter Ross wrote:

> Dear All,
>
> Can someone please explain:
>
> I have a C process and an Occam process running on the same transputer. I
> have a communication channel between them.
>
> At the Occam end the code looks like:
>
>         in ? byte; byte; byte
>
> where 'in' is a channel of type byte.
>
> At the C end I have:
>
>         ChanOut(chan.out, &array[0], 3) ;
>
> where 'array' is of type unsigned char. This does not work.
>
> However, the following does work:
>
>         int i;
>
>         for (i=0; i<3; i++)
>         {
>                 ChanOutChar(chan.out, array[i])
>         }
>
> I am guessing that this is due to the way the Occam channel is specified
> but could someone please gice the definitive explanation.

The in and output statements must be compatible

The statement:
 in ? byte; byte; byte
will compile to a sequence of 3 inputs of one byte.

The statement:
 ChanOut(chan.out, &array[0], 3) ;
Will probably (I am not familiar with parallel C) compile to an output of the
value 3 (length of data), followed by an OUT instruction of 3 bytes.

The for loop will compile to a sequence of 3 outputs of one byte.

If you want to input the array you must use a counted array in Occam,
something like (in a sort of pseudo Occam):

INT len:
BYTE array[3]:
CHAN OF INT::BYTE[] in:
in ? len::array

(Look in the manual for the correct syntax. It has been a while ago when I
programmed in Occam).

Otto

