Shop OBEX P1 Docs P2 Docs Learn Events
UDP for ENC28J60 — Parallax Forums

UDP for ENC28J60

localrogerlocalroger Posts: 3,451
edited 2013-04-03 17:55 in Propeller 1
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

Comments

  • RaymanRayman Posts: 14,665
    edited 2013-04-03 17:55
    Nice work. I've used Harrison's enc28j60 code in OBEX, but maybe that one doesn't have UDP.
    If, UDP takes less space, that's a plus...
Sign In or Register to comment.