You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following code doesn't work with the Native Ethernet library.
The code works with STM32duino with LWIP and with the WIZNet library
#include"Arduino.h"
#include<TeensyID.h>
#include<NativeEthernet.h>
#include<NativeEthernetUdp.h>uint8_t mac[6];
IPAddress localIP(10, 101, 1, 201);
IPAddress subnet(255, 255, 0, 0);
uint16_t localPort = 8001;
IPAddress remoteIP(10, 101, 1, 100);
uint16_t remotePort = 8000;
EthernetUDP udp;
voidsetup() {
teensyMAC(mac);
Serial.begin(9600);
Ethernet.begin(mac, localIP);
udp.begin(localPort);
}
voidloop() {
String message;
int size;
size = udp.parsePacket();
if (size > 0) {
// Fill the msg with all of the available byteswhile (size--) {
message += (char)(udp.read());
}
Serial.println(message);
message = String();
}
}
The application stop working when reaching message += (char)(udp.read());
If using the standard C++ string library it works as expected. Also when using a char buffer array.
This example works
#include"Arduino.h"
#include<TeensyID.h>
#include<NativeEthernet.h>
#include<NativeEthernetUdp.h>
#include<string>usingnamespacestd;uint8_t mac[6];
IPAddress localIP(10, 101, 1, 201);
IPAddress subnet(255, 255, 0, 0);
uint16_t localPort = 8001;
IPAddress remoteIP(10, 101, 1, 100);
uint16_t remotePort = 8000;
EthernetUDP udp;
voidsetup() {
teensyMAC(mac);
Serial.begin(9600);
Ethernet.begin(mac, localIP);
udp.begin(localPort);
}
voidloop() {
string message;
int size;
size = udp.parsePacket();
if (size > 0) {
// Fill the msg with all of the available byteswhile (size--) {
message += (char)(udp.read());
}
Serial.println(message.c_str());
message.erase();
}
}
The text was updated successfully, but these errors were encountered:
Following code doesn't work with the Native Ethernet library.
The code works with STM32duino with LWIP and with the WIZNet library
The application stop working when reaching
message += (char)(udp.read());
If using the standard C++ string library it works as expected. Also when using a char buffer array.
This example works
The text was updated successfully, but these errors were encountered: