EthernetPacketGet()是从以太网控制器的FIFO中读出一个以太网帧:
在FIFO中存储的一个帧是下面这样的:
+---------+----------+----------+----------+----------+
//! | | 31:24 | 23:16 | 15:8 | 7:0 |
//! +---------+----------+----------+----------+----------+
//! | Word 0 | DA 2 | DA 1 | FL MSB | FL LSB |
//! +---------+----------+----------+----------+----------+
//! | Word 1 | DA 6 | DA 5 | DA 4 | DA 3 |
//! +---------+----------+----------+----------+----------+
//! | Word 2 | SA 4 | SA 3 | SA 2 | SA 1 |
//! +---------+----------+----------+----------+----------+
//! | Word 3 | FT LSB | FT MSB | SA 6 | SA 5 |
//! +---------+----------+----------+----------+----------+
//! | Word 4 | DATA 4 | DATA 3 | DATA 2 | DATA 1 |
//! +---------+----------+----------+----------+----------+
//! | Word 5 | DATA 8 | DATA 7 | DATA 6 | DATA 5 |
//! +---------+----------+----------+----------+----------+
//! | Word 6 | DATA 12 | DATA 11 | DATA 10 | DATA 9 |
//! +---------+----------+----------+----------+----------+
//! | ... | | | | |
//! +---------+----------+----------+----------+----------+
//! | Word X | DATA n | DATA n-1 | DATA n-2 | DATA n-3 |
//! +---------+----------+----------+----------+----------+
//! | Word Y | FCS 4 | FCS 3 | FCS 2 | FCS 1 |
//! +---------+----------+----------+----------+----------+
最后读到缓冲区中之后是去掉RX FIFO中6个字节 FL MSB | FL LSB 和| FCS 4 | FCS 3 | FCS 2 | FCS 1 的一个标准的以太网帧,并传给了IP层。这里边尚不存在什么协议,只是把RX FIFO中的数据读取了一下。我对工业以太网不太了解,不过看上面的那个图,我觉得Ethercat好像就是对IP数据报的格式进行了修改。 |