paszkows@prlhp1.prl.philips.co.uk (paszkows) (11/01/88)
I have two 32 bit words, which for example are made up as follows: lint 1 bits 00-07 byte1 bits 07-23 int1 bits 23-31 int2 lsb lint 2 bits 00-07 int2 msb bits 08-15 byte2 bits 16-31 int3 I wish to transmit the two 32 bit integers over a link, but receive them in the format in which they are made up. In effect I do CHAN OF ANY chan.out, chan.in SEQ chan.out ! lint1 chan.out ! lint2 SEQ chan.in ? byte1 chan.in ? int1 chan.in ? int2 chan.in ? byte2 chan.in ? int3 At present I have tried this over a channel ( not a link yet ) and it does not work. As far as I am aware, when this is transmitted over a link, the two 32 bit words are chopped into eight bytes, with associated start, one, stop bits, so the input link is not aware of the format they are transmitted in, so it ought to be able to receive them as above. At a guess, because we have a CHAN OF ANY protocol, is not an identity byte, describing what format the next data is in, sent? ( ie: tt.out.int etc.. ) Can anyone verify that this will, or if not, can explain why not and why the comms over the channel, as described above, does not work. Thanks.
paszkows@prlhp1.prl.philips.co.uk (paszkows) (11/02/88)
In article <675@prlhp1.prl.philips.co.uk> paszkows@prlhp1.UUCP () writes: > > > chan.out ! lint1 > chan.out ! lint2 > > > SEQ > chan.in ? byte1 > chan.in ? int1 > chan.in ? int2 > chan.in ? byte2 > chan.in ? int3 > > Having posed the problem, I have managed to solve it myself. Read on for the solution. Occam 2 reference manual states that with a PROTOCOL OF ANY, the data sent is mapped into its constituent bytes, and output as an array. Input on this channel inputs the array of bytes and converts ( by retyping conversion ) the value to the type of the receiving variable. I am not convinced that the last statement holds true ( opinions ? ) as I had to do the retyping manually. Anyway, on input channel, read the data into a BYTE array of length equal to that of the sent data as shown below. -- retype the bytes into required format. BYTE byte1 RETYPES inword[5] BYTE byte1 RETYPES inword[0] : INT16 inta RETYPES [inword FROM 0 FOR 2 ] INT16 intb RETYPES [inword FROM 3 FOR 2 ] INT16 intc RETYPES [inword FROM 6 FOR 2 ] INT32 int1, int2 : -- the data being sent. CHAN OF ANY channel.a : SEQ PAR SEQ channel.a ! int1 channel.a ! int2 SEQ channel.a ? [ inword FROM 0 FOR 4 ] -- receive 4 bytes making up int1 channel.a ? [ inword FROM 4 FOR 4 ] -- receive 4 bytes making up int2