Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 6 months ago.
Data transmission stops during Ethernet communication
The server receives only 7 times each time during 10 transmissions.
What's wrong?
Thank you for your analysis.
My Test board is 'NUCLEO F207ZG'
AnalogIn & Ethernet Testing
#if !FEATURE_LWIP # error [NOT_SUPPORTED] LWIP not supported for this target #endif #include "mbed.h" #include "EthernetInterface.h" #include "TCPSocket.h" AnalogIn analog_value(A0); DigitalOut led(LED1); const char* SERVER_ADDRESS = "***.***.***.***"; const int SERVER_PORT = 3000; int main() { EthernetInterface eth; TCPSocket sock; eth.connect(); sock.open(ð); sock.connect(SERVER_ADDRESS, SERVER_PORT); char Meas_Buf[64]; float Meas_Ai; int Cnti =1; while(Cnti <= 10) { memset(Meas_Buf, '0', sizeof(Meas_Buf)); Meas_Ai = analog_value.read(); // Converts and read the analog input (0.0 ~ 1.0) Meas_Ai = Meas_Ai * 3.3; // Change the value to be in the 0 to 3.3V range sprintf(Meas_Buf,"YEAR-MON-DAY H:M:S|ID000001|.3f|%d|", Meas_Ai, Cnti); sock.send(Meas_Buf, sizeof(Meas_Buf)); wait(1); Cnti ++; } sock.close(); eth.disconnect(); }