0
votes

I'm struggling with the Transmission of the UDP packets. I'm using "Wireshark" as a control for incoming packets. The IP adress of the UDP packet is my fixed PC's configured IP right? I changed my script but I still don't receive any packages :/

Thanks!

Here's my code:

//Version 1.05

//necessary libraries
#include <SPI.h>
#include <Ethernet2.h>
#include <EthernetUdp2.h>

//Pin settings
#define CTD 19

//Network Settings
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xEC, 0xAB };  //set MAC Address Ethernet Shield (Backside)
byte ip[]  = { XXX, XXX, X, X };                      //set IP-Address
byte gateway[] = { XXX, XXX, X, X };                  //set Gateway
byte subnet[]  = { 255, 255, 255, 0 };                //set Subnetmask


//local UDP port to listen on
unsigned int localPort = 5568;

//Recipient IP
IPAddress RecipientIP(XXX, XXX, X, X);

//Recipient UDP port
unsigned int RecipientPort = 8888;

//Buffer for sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];

//EthernetUDP instance
EthernetUDP Udp;

//CTD data
int incomingData = 0;


void setup()
{
   //Start Ethernet
  Ethernet.begin(mac, ip);

  //Start UDP
  Udp.begin(localPort);

  //for debug only
  Serial.begin(9600);

  //Serial baud rate for CTD
  Serial1.begin(1200);

  //Version 1.05
Serial.print("Version 1.05");

  //CTD
  pinMode(CTD, INPUT);
}

void loop()
{

//If CTD is sending
if (Serial1.available())
{
  //read incoming data
  incomingData = Serial1.read();

  //for debug only
  Serial.print("Data: ");
  Serial.println(incomingData, BIN);
}

//Send UDP packets
int packetSize = Udp.parsePacket();
  if (packetSize) 
  {

    //Debug only
    Serial.print("Packet");
    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);

    // send to the IP address and port
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(incomingData);
    Udp.endPacket();
  }
}
1
You need some software on the other end to receive the packetsPeter Bruins
I'm using Wireshark to see if there are incoming packets and it doenst report any UDP from the Arduino's IPTheTris
WireShark does not receive (or send) any date from/to the sender. You need a server script or piece of software that listens on certain port for the UDP packets. Check the UdpNTPClient example under Ethernet example projects in your Arduino IDE.OpalApps
@OpalApps WireShark doesn't send anything but it most certainly does receive every IP packet that arrives at the host it is running on. That's what it's for.user207421
@OP This code reads before it sends. Where is it reading from? and is anything being sent to it?user207421

1 Answers

0
votes

Install Netcat. Then use the following syntax on your recipient computer: sudo nc -l 8888 Fire up the arduino, and you should see the output on your shell.