Pages: [1]   Go Down
Author Topic: Problems with reading RAW packages  (Read 271 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am working on an Arduino Ethernet project that will become a node on our old Ethernet instrument network. There is a lot of traffic on this network and I have a lot of trouble getting the w5100 library to work.

The code below should be the bare minimum to look for a message and then send a reply. If I comment any receiving code out it will send messages every 700 us. If I run the code below I get nothing although there is activity from other nodes on the network about every millisecond. The interesting thing is that if I comment the

W5100.recv_data_processing(s, RXbuf, RXbuflen);

line out, it will immediately start to transmit when there is other activity on the network as intended. Obviously I don't get any data from the incoming messages in this case.

Any idea of what's wrong an why does the W5100.recv_data_processing apparently get stuck?

Thanks,

Jens.
 



Code:
#include <SPI.h>         
#include <Ethernet.h>
#include <utility/w5100.h>

SOCKET s; // our socket that will be opened in RAW mode
byte RXbuf[1980]; // receive buffer
byte TXbuf[64] = {
  char('A'),
  char('R'),
  char('D'),
  char('U'),
  char('I'),
  char('N'),
  char('0'),
  char('0'),
  char('0'),
  char('0'),
  char('9'),
  char('0')}; // buffer to send through socket
int TXbuflen; // length of data to send
int RXbuflen;


void setup() {

  // initialize the w5100 chip and open a RAW socket 
  W5100.init();
  W5100.writeSnMR(s, SnMR::MACRAW);
  W5100.execCmdSn(s, Sock_OPEN);

}

void loop() {

  RXbuflen = W5100.getRXReceivedSize(s);
 
  if (RXbuflen > 0)
  {
    W5100.recv_data_processing(s, RXbuf, RXbuflen); //Comment this line out and it essentially becomes stuck
    W5100.execCmdSn(s, Sock_RECV);
   
    //Insert the RX buflen just to do something harmless
    TXbuf[16] = lowByte(RXbuflen);
    TXbuf[17] = highByte(RXbuflen);
   
    // sending buffer
    TXbuflen=64;
    W5100.send_data_processing(s, TXbuf, TXbuflen);
    W5100.execCmdSn(s, Sock_SEND_MAC);
  }
}
Logged

Pages: [1]   Go Up
Jump to: