4.4. Receiving Packets

Raw1394 maintains a fixed-size ringbuffer of packets in kernel memory. The buffer is filled by the low-level driver as it receives packets from the bus. It is your application's job to process each packet, after which the buffer space it occupied can be re-used for future packets.

The isochronous receive handler you provided will be called from raw1394_loop_iterate() after each packet is received. Your handler is passed a pointer to the first byte of the packet's data payload, plus the packet's length in bytes (not counting the isochronous header), the cycle number at which it was received, the channel on which it was received, and the "tag" and "sy" fields from the isochronous header. Note that the packet is at this point still in the kernel's receive buffer, so the data pointer is only valid until the receive handler returns. You must make a copy of the packet's data if you want to keep it.

The receive handler is also passed a "packet(s) dropped" flag. If this flag is nonzero, it means that one or more incoming packets have been dropped since the last call to your handler (usually this is because the kernel buffer has completely filled up with packets or a bus reset has occurred).