This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TCPnet SMTP Issues

I have implemented the TCPnet library and a simple routine to send an email to myself. It works, however only about 50% of the time; one of several things causes it to fail: it doesn't ever receive and IP address and gets assigned 169.254.x.x and than nothing works, or it gets a valid IP but then either has a server timeout error or email failed to send error.

When it works it works fine and all data is transferred and email comes through correctly and to the correct address. But half the time it fails. I have the timer tick already set to max of 10ms so it is going as fast as the library will allow.

Any ideas as to why it may not be working all of the time?

  • Did you try to use a debug TCPnet library? Debug messages might help you to find the cause of a problem.

  • I am looking into that, it may not be possible with my specific hardware setup as my serial ports are in use, but it may be possible.

  • Note that an UART isn't the only route to get out debug prints from an embedded device.

    It might be possible to use an SPI interface, CAN etc to stream out the data - then take another embedded device to convert back into USB or UART to make the data more accessible to a PC.

  • I will keep that in mind.

    In an attempt to get the debug libraries working I was going to just print the debug info out to a display built into the device, however whenever I import the library file that supports debug and the Net_Debug.c file my code doesn't run at all; almost as if it locks up as soon as starting.

    In addition in the example code it says to override putchar() to output data to a custom location, but on this site - www.keil.com/.../rlarm_tn_debug_redir.htm - it says sendchar(). Neither seemed to work but there is conflicting documentation there.

  • You did not mention a device type which you are using. For Cortex-M devices you can use ITM as a debug print channel. So you can make a very fast print over ULINK2 or ULINKpro, and see that in uVision debug window (uVision Debug->View->Serial Windows->Debug (printf) Viewer).

    ITM is a Cortex-M core extension, it does not need any peripheral. To use it, you need uVision and a connected ULINK2/pro debugger. You can also capture debug output to a text file from within uVision debugger.

    With this code, you can print debug messages to ITM from TCPnet:

    int fputc (int ch, FILE *f) {
      if ((ITM_TCR & ITM_TCR_ITMENA_MSK) && (ITM_TER & (1UL << 0))) {
        while (ITM_PORT0_U32 == 0);
        ITM_PORT0_U8 = (uint8_t) ch;
      }
      return (ch);
    }