sstaub / Ethernet3

Ethernet library for Arduino and Ethernetshield2 / WIZ550io / WIZ850io / USR-ES1 with Wiznet W5500 chip
Other
76 stars 34 forks source link

Problem of multiple servers when porting from ETHERNET/ETHERNET2 #43

Closed skrenda closed 2 years ago

skrenda commented 3 years ago

Hello,

I have problem using ETHERNET3 library. My code works on ETHERNET & ETHERNET2, but have problems with unexpected send delays, so I'm trying ETHERNET3 whis seems to be more robust, but I have problem with secondary server running on other TCP port. I'm using one server for streaming of meassurement data and secondary for Configuration of device. Code is running on ARDUINO DUE, and main loop contains many other functions so I extracted only related parts. Streeming connection seems to be fine, but control one is not working. Can you advice what is wrong (same approach was ok with ETHERNET.h). Thank you for help.

See my code extracted here:

EthernetServer server(80); EthernetServer server1(88);

EthernetClient DataStream; EthernetClient EthConfig;

void setup() { //For Ethernet library V 3.0
Ethernet.setCsPin(10); //Set CS = 10
Ethernet.init(1); //-> 1 Socket with 16k RX/TX buffer

Ethernet.begin(CS_CFG.str.MAC_addr, CS_CFG.str.IP_addr,subnet, gateway);

server.begin();
server1.begin();

}

void loop() { // Ethernet // Listen for incoming clients EthernetClient DataStream = server.available(); EthernetClient EthConfig = server1.available();

// Ethernet data streaming to PC
if (DataStream) {
if (DataStream.connected()) { // ETH TCP connection status
if (DataStream.available()) { // If some bufers are full to be send
DataStream.write(DAQ_buff[DAQ_buff_indx_sent].Bytes,ETH_sent_buff_length); } } } else { //No active connection

  }

// Ethernet configuration channel to PC
  if (EthConfig) {
    if (EthConfig.connected()) {
      if (EthConfig.available()) {        
        //Read 5 characters of command
        EhtCmd_string="";
        for(int i=0; i < 5; i++){
          EthChar=EthConfig.read();
          EhtCmd_string += EthChar;
        }

          if (EhtCmd_string == "GETCS"){                                      //Send parameters
            EthConfig.write(CS.Bytes,sizeof(CS));
            //EthConfig.write(reinterpret_cast<char*>(&CS),sizeof(CS));    
            InfoMsg("GETCS");       
          }

          if (EhtCmd_string == "GETCA"){                                      //Send Act calibration parameters
            EthConfig.write(Calibration.Bytes,sizeof(Calibration));
          }

          if (EhtCmd_string == "GETxx"){                                      //Test
            EthConfig.write(DAC0); 
          }     
      }
    }
  }

}

sstaub commented 3 years ago

Sorry, in the moment I have no time to figure out this issue. I know that there are many problems with TCP I will look in summer.