lpcware

LPC ETHERNET REMOTE SERVER

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by rocketfuel on Tue Oct 07 19:14:18 MST 2014
Hi everyone.

At work I have been asked to build a remote server to watch/control an old TV broadcasting unit. Basically, all i have to do is to read 8 ADC values, a few digital outputs and to send a few commands to its digital inputs.

Currently i have a visual basic app wich sends and receives strings (commands). This app has been fully tested and works perfectly. It sends string commands in the following way:

COMMAND:|:

And receives a string in the following way:

COMMAND:|:VALUEADC1:|:VALUEADC2:|:VALUEADC3.......:|:DIGITALVALUE1:|:DIGITALVALUE2:|:....

Now talking about LPC1769 i did the following: i took EASYWEB example and modified it. At first i made it send a simple string containing values of ADC in an infinite loop and worked succesfully. But i had to implement input commands so right now im stuck at that point.

I decided to make the board to echo every command string i send. Here is the code (pay attention to red line):

void HTTPServer(void)
{
if (SocketStatus & SOCK_CONNECTED)
{
if (SocketStatus & SOCK_DATA_AVAILABLE)
{
memcpy(TCP_RX_BUFTEMP, TCP_RX_BUF, sizeof(TCP_RX_BUF));
TCPReleaseRxBuffer();

if (SocketStatus & SOCK_TX_BUF_RELEASED)
{
[color=#c03]HTTPBytesToSend = sizeof(TCP_RX_BUFTEMP)-1;[/color]
Buffer = (unsigned char*)TCP_RX_BUFTEMP;

if (HTTPBytesToSend > MAX_TCP_TX_DATA_SIZE)
{
memcpy(TCP_TX_BUF, Buffer, MAX_TCP_TX_DATA_SIZE);
HTTPBytesToSend -= MAX_TCP_TX_DATA_SIZE;
Buffer += MAX_TCP_TX_DATA_SIZE;

TCPTxDataCount = MAX_TCP_TX_DATA_SIZE;
TCPTransmitTxBuffer();
}
else
{
if (HTTPBytesToSend)
{
memcpy(TCP_TX_BUF, Buffer, HTTPBytesToSend);
TCPTxDataCount = HTTPBytesToSend;
TCPTransmitTxBuffer();
HTTPBytesToSend = 0;
}
}
}
}
}
}

What this code does is: It echoes only the first 3 characters unless i especify +something (+20 for example) in the red line but, of course, it will print the string + garbage because it doesnt know where the string finishes...

So Sizeof(TCP_RX_BUFTEMP) is not working and i am pretty sure its because TCP_RX_BUFTEMP is something different than a simple array like it comes with easyweb. I cant understand how RX BUFFER is implemented.

Any help would be much appreciated!

Outcomes