Ethernet "read" modification

10 Jul 2010 . Edited: 10 Jul 2010

Hello! I am working with an Ethernet project and I was wondering if it is possible to change the read method of the Ethernet class.

Currently, read will write the up to size bytes into data ( int read(char *data, int size) ) but I want to sent those bytes directly to an 8bit parallel output of the mbed and not store those to an array.

Furthermore, the read method returns the Destination and Source address, Type/Length, Data, Pad, Checksum of the Ethernet packet or only the first three?

13 Jul 2010 . Edited: 13 Jul 2010

user avatar Ioannis Kedros wrote:


Furthermore, the read method returns the Destination/Source address, Type/Length, Data, Pad, Checksum of the Ethernet packet or only the first three?

OK, after some testing with “Ethernet Packet Creators” software I realize that the method read returns all the information of the packet, including the pad and checksum. That is really good according to the project…

 

 

user avatar Ioannis Kedros wrote:

Currently, read will write the up to size bytes into data ( int read(char *data, int size) ) but I want to sent those bytes directly to an 8bit parallel output of the mbed and not store those to an array.

 

But my first problem remains. Is it possible to change the read method and not store the bytes into an array but transmit those directly to a serial port or parallel port? Is it possible to find the Ethernet Class in order to do those changes?

14 Jul 2010

I'm afraid that at the moment, the code for the mbed Library is closed source. Also, by the nature of the ethernet block in the LPC1768/LPC2368, it was be non-trivial to implement a byte transfer on reception - it really is designed around receiving and transmitting entire packets (there even being a section of RAM set aside for this).

14 Jul 2010 . Edited: 14 Jul 2010

Thanks Jon!

14 Jul 2010 . Edited: 14 Jul 2010

You don't actually have to read the entire buffer out in one go - you can grab a byte at a time using the read() method, and process that:

Ethernet intf;

int rxsize = intf.receive();
for(int i = 0; i < rxsize; i++)
{
    char abyte;
    intf.read(&byte, 1);
    process(abtye);      // Your routine to process that  byte
}
Of course, this will only work once the packet has been fully received.

14 Jul 2010 . Edited: 14 Jul 2010

Yes, I know that and I am using it already! I just want to pre-compute some packet data (basically in the header section) and after that to transmit some of those packets directly to a second mbed (without losing time for memory storage) for second phase processing while the first one will still reading packets. This will create a parallel processing architecture. After that I have to rearrange the architecture etc…