UDP for ENC28J60
localroger
Posts: 3,451
This application demonstrates UDP as both a client and server on the ENC28J60. The sample application receives serial data until a delimiter is received and transmits the collected packet as a UDP datagram, and transmits received datagrams to the serial port. It's very dependent on Harrison's TCP driver low level code for controlling the ENC28J60, but the high level logic is written very differently and more simply since I would expect this to mostly be used for point-to-point applications like, say, serial over ethernet. I've also included the VB6 test application I wrote, which is coded to the API so it has no dependencies except the VB6 runtime; the compiled application should run in Linux under Wine. (I'd be interested in hearing if anyone cares to test that.) There are also numerous freeware UDP test terminals available.
The sample also implements Ping replies (as posted previously). Because it is so simple the code will probably be a lot easier to understand and modify if you need to link a couple of Props or a Prop to a PC over a routed network. It could easily be extended to handle multiple connections without making it much bigger and without using multiple cogs.
The UDP code is very strikingly smaller than the TCP suite, coming in at 1500 longs versus 2700+. If only short UDP packets are to be handled the driver can be stuffed into 1150 longs, and if space is really tight making it server-only (which eliminates the need for ARP requests and their handling) drops another 100 longs and removing Ping support another 40, which gets it below 1000 longs. And that's without even trying to reuse the PASM images for other data. Also, only three cogs are used; other than the SPI driver for the ENC28J60 and the FullDuplexSerial UART, only one Spin cog is used for all the UDP and business logic.
UDP_enc28j60_demo - Archive [Date 2013.04.03 Time 10.44].zip
UDPtest.zip
The sample also implements Ping replies (as posted previously). Because it is so simple the code will probably be a lot easier to understand and modify if you need to link a couple of Props or a Prop to a PC over a routed network. It could easily be extended to handle multiple connections without making it much bigger and without using multiple cogs.
The UDP code is very strikingly smaller than the TCP suite, coming in at 1500 longs versus 2700+. If only short UDP packets are to be handled the driver can be stuffed into 1150 longs, and if space is really tight making it server-only (which eliminates the need for ARP requests and their handling) drops another 100 longs and removing Ping support another 40, which gets it below 1000 longs. And that's without even trying to reuse the PASM images for other data. Also, only three cogs are used; other than the SPI driver for the ENC28J60 and the FullDuplexSerial UART, only one Spin cog is used for all the UDP and business logic.
UDP_enc28j60_demo - Archive [Date 2013.04.03 Time 10.44].zip
UDPtest.zip
Comments
If, UDP takes less space, that's a plus...