Code Monkey home page Code Monkey logo

enc28j60-tcpip-solution's Introduction

MCHP

ARCHIVED TCP/IP Lite solutions using ENC28J60

Please refer to the following links for updated solutions for PICs and AVRs:

TCP/IP Lite solutions using ENC28J60

This repository provides MPLAB X IDE projects that can work out of the box. The solutions that are included in the repository include functionality for UDP, TCP Server and TCP Client Demos. Note that the TCP/IP Lite stack needs to be serviced every 1 second and the timer callback function needs to be set to 1 second.


Related Documentation

More details can be found at the following links:

Software Used

Hardware Used


UDP Solution

  1. Open MPLABX IDE.
    mplabIcon
  2. From the downloaded projects, open enc28j60-udp-solution.X.
  3. Open Windows Command Prompt application on your PC. Type “ipconfig” to get the IP address of your PC.
    ipconfig
  4. Sending UDP Packets: In udp_demo.c, under the function UDP_DEMO_Send ():

- Modify the Destination IP address with PC’s IP address as noted in Step 3.
- Destination Port (anything in the range of dynamic ports)

destinationPort


5. Receiving UDP Packets: In Source Files\MCC generated files\ udpv4_port_handler_table.c, add the following code:
- In UDP_CallBackTable, add the following code to perform UDP Receive:

udpReceive


6. Click on Program Device to program the code to the device.
7. Launch Wireshark. From the Capture menu, click Options. Select an Interface from the list to which your board and PC are connected, click Start for capturing packets.
e.g.: Local Area Network
8. In Wireshark, set the filter field as bootp||arp||icmp.

wiresharkFilter

9. In Wireshark, notice the DHCP packets handshake to get the device IP address.

wiresharkDHCPCapture

10. In Wireshark, double click on “Offer” packet. Expand “Dynamic Host Configuration Protocol” to get the device IP address.

DHCPPacket

11. Open the Java application TCPIP_Demo.exe. Go to the UDP tab and assign the same port number as ‘DestPort’(65531). Click on ‘Listen’ button. Click “Allow Access” if warning occurs. Assign the IP Address of your board which is found from step 10(192.168.0.37). Click on ‘Claim’ button.

udpDemoGUI


12. In Wireshark, set the filter field as bootp||udp.port==65531.
13. In Demo GUI, click on LED 1, 2, 3, 4 to light the LEDs D1, D2, D3, D4, respectively and observe the Wireshark capture.

udpWiresharkPacket


14. In Demo GUI, type data(e.g.: “Hello World”) inside Send Data box and press the Send button and observe the Wireshark capture.

udpWiresharkSend


15. On the Curiosity HPC Board, press the Switch S1 and observe the Wireshark capture.

udpWiresharkReceive


TCP Client Solution

  1. Open MPLABX IDE.
    mplabIcon
  2. From the downloaded projects, open enc28j60-tcp-client-solution.X.
  3. Open Windows Command Prompt application on your PC. Type “ipconfig” to get the IP address of your PC.
    ipconfig
  4. Modify the server IP address with PC's IP address in tcp_client_demo.c under function call TCP_Client_Initialize:
    tcpClientInit
  5. Click on Program Device to program the code to the device.
  6. Open the Java application TCPIP_Demo.exe. Go to the TCP Server Demo tab and assign the port number as ‘65534’. Click on ‘Listen’ button. The status of the TCP Connection is printed inside the STATUS text box.
    tcpClientSolutionGUI

Also in Wireshark, observe the TCP packets by setting the filter “tcp.port == 65534”.

tcpWiresharkPacket

6. After the connection is established:
- Type text inside the Send text box and click on ‘Send’ button. The text sent is displayed inside the Sent/Received Data box.

tcpSend


Also in Wireshark, observe the TCP packets by setting the filter “tcp.port == 65534”

tcpWiresharkSend


- Click on the Led buttons {0, 1, 2, 3, 4}. This will toggle LEDs on board.

tcpClientReceive


Also in Wireshark, observe the TCP packets by setting the filter “tcp.port == 65534”

tcpClientWiresharkReceive

7. Push ‘Disconnect’ button, to close the TCP Connection. A client disconnected message will appear on the STATUS text box.

TCP Server Solution

  1. Open MPLABX IDE.
    mplabIcon
  2. From the downloaded projects, open enc28j60-tcp-server-solution.X.
  3. Click on Program Device to program the code to the device.
  4. Launch Wireshark. From the Capture menu, click Options. Select an Interface from the list to which your board and PC are connected, click Start for capturing packets.
    e.g.: Local Area Network

5. In Wireshark, set the filter field as bootp||arp||icmp.

wiresharkFilter

6. In Wireshark, notice the DHCP packets handshake to get the device IP address.

wiresharkDHCPCapture

7. In Wireshark, double click on “Offer” packet. Expand “Dynamic Host Configuration Protocol” to get the device IP address.

DHCPPacket

8. Open the Java application TCPIP_Demo.exe. Go to the TCP Client Demo tab, assign the board IP address as Server IP address in the GUI from step 7. Assign the port number as ‘7’. Click on ‘Connect’ button. The status of the TCP Connection is printed inside the STATUS text box.

tcpServerDemoGUI

9. After the connection is established:
- Type text inside the Send text box and click on ‘Send’ button. The text sent is echoed and displayed inside the Sent/Received Data box.

tcpServerSend


- Also in Wireshark, observe the TCP packets by setting the filter “tcp.port == 7”

tcpServerWiresharkSend


10. Push ‘Disconnect’ button, to close the TCP Connection. TCP server closing the connection message will appear on the STATUS text box.

enc28j60-tcpip-solution's People

Contributors

pic-avr-github-admin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.