Different behavior for client.write in library ethernet version 2

Hello,

I am streaming data from a Raytek MP150 temperature line scanner to a Leonardo with an old ethernet shield. Communication and data processing was a bit slow so I bought a Due and a new ethernet shield to improve. At the same time, I updated the ethernet library to version 2.0. Now, after updating to version 2.0, I find that my sketch is behaving differently than before. The problem:

After initialization, I send some setup strings to the scanner to set scan rate etc.:

if (client.connect(server, 2727)) {
Serial.println(“connected”);
client.println(“DMB”);
Serial.println(“DMB - temperature scaled to eight bit”);
WriteClient2Serial();

Then streaming from the line scanner is initiated by sending a byte to the scanner:
delay(500);
client.write(0x02);

After this write, the scanner starts to stream data.
However, after updating to lib ethernet version 2, the streaming doesnt start. It is like the client.write(0x02) is no longer working. All the previous char string write still works.
I tried to delete the new library and then the problem disappeared!

Anybody have any idea what is wrong? I would really like to use the new library so I can use my new W5500 ethernet shield.

Thank you!

Kind regards,
Anders Bach

try client.flush() after the write

Thank you for your input. I just tried it - no change in behavior...

Have you done a test with the exact same hardware using both Ethernet library version 2.0.0 and the older version of the library, or are you changing the library, board, and shield all at the same time?

Which version is the older Ethernet library that's working for you? You can find it by:

  • Sketch > Include library > Manage Libraries
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "ethernet".
  • Press Enter.
  • In the search results, you will see "Ethernet by Various" and the installed version number will be displayed there.

pert:
Have you done a test with the exact same hardware using both Ethernet library version 2.0.0 and the older version of the library, or are you changing the library, board, and shield all at the same time?

Which version is the older Ethernet library that's working for you? You can find it by:

  • Sketch > Include library > Manage Libraries
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "ethernet".
  • Press Enter.
  • In the search results, you will see "Ethernet by Various" and the installed version number will be displayed there.

older version of the Ethernet library will not work with W5500, but other combinations should be tested.
I would start with new shield on Leonardo

Hi pert and juraj:

Old version that works is version 1.1.2

Hardware setup tested:

Leonardo + old ethernet shield + lib ethernet 1.1.2 → client.write(0x02) WORKS
Leonardo + old ethernet shield + lib ethernet 2.0 → client.write(0x02) DOES NOT WORK
DUE + old ethernet shield + lib ethernet 1.1.2 → client.write(0x02) WORKS

Leonardo + new ethernet shield 2 + lib ethernet 1.1.2 → not connecting to server
Leonardo + new ethernet shield 2 + lib ethernet 2.0 → client.write(0x02) DOES NOT WORK
DUE + new ethernet shield 2 + lib ethernet 2.0 → client.write(0x02) DOES NOT WORK

Seems like it is the lib ethernet 2.0 that behaves differently.

you could try the Ethernet2 library. it is only for W5500

Tried the Ethernet2 library:

IT WORKS!

Both on Leonard and DUE with ethernet shield 2.

Thank you!!!!!