tags:

views:

359

answers:

1

I am using pipes to transfer information between two vxWorks tasks.

Here is a code sample:


Init()
{
   fd = open("/pipe/mydev", O_RDWR, 0777);
...
}

taskRx()
{
   ...
   len = read(fd, rxbuf, MAX_RX_LEN);
   ...
}
taskTx()
{
   ...
   len = write(fd, txbuf, txLen);
   ...
}

If we send a message that is longer than MAX_RX_LEN, (ie txLen > MAX_RX_LEN) we do 2 reads to get the remainder of the message.

What we noticed is that the 2nd read didn't receive any data!

Why is that?

+1  A: 

VxWorks' pipe mechanism is not stream based (unlike unix named pipes).

It is a layer on top of the vxWorks message Queue facility. As such, it has the same limitations as a message queue: when reading from the pipe, you are really reading the entire message. If your receive buffer does not have enough space to store the received data, the overflow is simply discarded.

When doing a receive on a message Queue or a pipe, always make sure the buffer is set to the maximum size of a queue element.

Benoit