Specifications

SLAA137A
24 MSP430 Internet Connectivity
SOCK_TX_BUF_RELEASED (Bit 3)
This flag indicates whether the application can change the contents of the transmit buffer or
modify the TCPTxDataCount variable. This flag is set by the stack if the previous packet sent
was acknowledged properly. This realizes a kind of handshake mechanism to protect the
transmit buffer from overwriting its contents. For the common way of sending data, see
description of the function TCPTransmitTxBuffer().
SOCK_ERROR (Bits 4 to 7)
If an error occurs while initiating a connection or transferring data, the stack writes an error code
to the upper nibble of register SocketStatus. By reading and interpreting this value, the
application can find out the reason for this error. It is recommended to get the error code by
isolating the upper nibble (AND-operation with SOCK_ERROR_MASK). The occurring of an
error but SOCK_ERR_OK immediately closes the connection. Table 6 gives an overview about
the error codes.
Table 6. Stack Error Codes
Error code Reason
SOCK_ERR_OK No error.
SOCK_ERR_ARP_TIMEOUT
Error during an ARP request occurred. The MAC address of the other TCP could
not be found. The other host is not connected to network or is not able to answer.
SOCK_ERR_TCP_TIMEOUT Timeout error during a TCP session occurred. Although the TCP segment was
sent several times, it was not acknowledged by the other TCP. May happen on a
very unreliable or interrupted connection.
SOCK_ERR_CONN_RESET A request to open a connection or an already existing connection was reset by
the other TCP. Either the other TCP cannot communicate at the given port or the
application layer of the other TCP has reset the connection (for example pushing
the STOP-button in an Internet browser).
SOCK_ERR_REMOTE A fatal error of the remote TCP led to the sending of an invalid segment.
SOCK_ERR_ETHERNET The TCP/IP stack was not able to transmit data via ethernet (the LAN controller
provided no free buffer space for sending frames). This error occurs on cutting
the network cable (no LINK pulses are detected by the network controller).
4.4 HTTP Server Application Example
As an example of how to use the previously described TCP/IP stack, a demonstration HTTP
server was implemented. This server provides an HTML web page that is stored in MCU flash
memory. The module waits for an incoming connection, transfers the web page, closes the
connection and waits for another client to connect. The content of this web page is adapted
dynamically to physical values. In detail, two bar graph displays are implemented for showing
A/D converter values.
4.4.1 Software Description
This demonstration HTTP server is an example for the non-blocking programming style
demanded in the API paragraph (Section 4.3), to keep on calling the DoNetworkStuff() function
periodically. The source file name is easyweb.c and its most important function is HTTPServer().
Figure 13 shows the flowchart of this module.