PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : Easy web



hassan.hamidi
12-07-2012, 00:55
می خواستم بدونم برنامش چطوری عمل میکنه؟
من برنامه ی EXAMPLEش رو دارم ولی نمیدونم در حالت کلی چطور عمل می کنه تا در واقع یه اطلاعاتی بدست بیارم که براساس اون بشه الگوریتم اصلی رو فهمید تا برنامه ای معادل واسش نوشت؟
اگر ممکنه هرقدر که در موردش می دونید کمک کنید؟:hi:
اصل برنامه:

/************************************************** ****************
***** *****
***** Name: easyweb.c *****
***** Ver.: 1.0 *****
***** Date: 07/05/2001 *****
***** Auth: Andreas Dannenberg *****
***** HTWK Leipzig *****
***** university of applied sciences *****
***** Germany *****
***** Func: implements a dynamic You can see links before reply by using *****
***** the easyWEB-API *****
***** *****
************************************************** ****************/

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include "LPC17xx.h"

#define extern

#include "easyweb.h"

#include "type.h"

#include "EMAC.h"

#include "tcpip.h"

#include "webpage.h" )

unsigned int pagecounter = 100;

unsigned int adcValue = 0;

extern void TCPClockHandler(void);

volatile DWORD TimeTick = 0;

/* SysTick interrupt happens every 10 ms */

void SysTick_Handler (void) {
TimeTick++;
if (TimeTick >= 20) {
TimeTick = 0;
LPC_GPIO2->FIOPIN ^= 1 << 0;
TCPClockHandler();
}
}
 
 

//void main(void)

int main(void)
{

//InitOsc(); // Keil: No oscillator initialization necessary at this time.
//InitPorts(); // Keil: No port initialization necessary at this time.

SystemInit(); /* setup core clocks */

SysTick_Config(SystemFrequency/100); /* Generate interrupt every 10 ms */

LPC_GPIO0->FIODIR |= 1 << 21; // ÉèÖÃLEDÓÐЧ

LPC_GPIO0->FIOPIN |= 1 << 21;
LPC_GPIO2->FIODIR |= 1 << 0; /* P2.0 defined as Output (LED) */

LPC_PINCON->PINSEL3 |= (3ul<<30); /* P1.31 is AD0.5 */

LPC_SC->PCONP |= (1<<12); /* Enable power to ADC block */

LPC_ADC->ADCR = (1<< 5) | /* select AD0.5 pin */

(4<< 8) | /* ADC clock is 25MHz/5 */

(1<<21); /* enable ADC */
TCPLowLevelInit();

/*
*(unsigned char *)RemoteIP = 24; // uncomment those lines to get the
*((unsigned char *)RemoteIP + 1) = 8; // quote of the day from a real
*((unsigned char *)RemoteIP + 2) = 69; // internet server! (gateway must be
*((unsigned char *)RemoteIP + 3) = 7; // set to your LAN-router)

TCPLocalPort = 2025;
TCPRemotePort = TCP_PORT_QOTD;

TCPActiveOpen();

while (SocketStatus & SOCK_ACTIVE) // read the quote from memory
{ // by using the hardware-debugger
DoNetworkStuff();
}
*/

You can see links before reply = 0; // clear You can see links before reply's flag register

TCPLocalPort = TCP_PORT_You can see links before reply // set port we want to listen to


while (1) // repeat forever

{
if (!(SocketStatus & SOCK_ACTIVE)) TCPPassiveOpen(); // listen for incoming TCP-connection

DoNetworkStuff(); // handle network and easyWEB-stack

// events

You can see links before reply();
}
}



void You can see links before reply(void)
{
if (SocketStatus & SOCK_CONNECTED) // check if somebody has connected to our TCP

{
if (SocketStatus & SOCK_DATA_AVAILABLE) // check if remote TCP sent data

TCPReleaseRxBuffer(); // and throw it away

if (SocketStatus & SOCK_TX_BUF_RELEASED) // check if buffer is free for TX

{
if (!(You can see links before reply & You can see links before reply)) // init byte-counter and pointer to webside

{ // if called the 1st time

You can see links before reply = sizeof(WebSide) - 1; // get HTML length, ignore trailing zero

PWebSide = (unsigned char *)WebSide; // pointer to HTML-code

}
if (You can see links before reply > MAX_TCP_TX_DATA_SIZE) // transmit a segment of MAX_SIZE

{
if (!(You can see links before reply & You can see links before reply)) // 1st time, include You can see links before reply

{
memcpy(TCP_TX_BUF, GetResponse, sizeof(GetResponse) - 1);
memcpy(TCP_TX_BUF + sizeof(GetResponse) - 1, PWebSide, MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1);
You can see links before reply -= MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
PWebSide += MAX_TCP_TX_DATA_SIZE - sizeof(GetResponse) + 1;
}
else

{
memcpy(TCP_TX_BUF, PWebSide, MAX_TCP_TX_DATA_SIZE);
You can see links before reply -= MAX_TCP_TX_DATA_SIZE;
PWebSide += MAX_TCP_TX_DATA_SIZE;
}

TCPTxDataCount = MAX_TCP_TX_DATA_SIZE; // bytes to xfer

InsertDynamicValues(); // exchange some strings...

TCPTransmitTxBuffer(); // xfer buffer

}
else if (You can see links before reply) // transmit leftover bytes

{
memcpy(TCP_TX_BUF, PWebSide, You can see links before reply);
TCPTxDataCount = You can see links before reply // bytes to xfer

InsertDynamicValues(); // exchange some strings...

TCPTransmitTxBuffer(); // send last segment

TCPClose(); // and close connection

You can see links before reply = 0; // all data sent

}
You can see links before reply |= You can see links before reply // ok, 1st loop executed

}
}
else

You can see links before reply &= ~You can see links before reply // reset help-flag if not connected

}

// samples and returns the AD-converter value of channel 2

unsigned int GetAD7Val(void)
{

// Keil: function replaced to handle LPC1768 A/D converter.

unsigned int val;
LPC_ADC->ADCR |= (1<<24); /* start conversion */

while (!(LPC_ADC->ADGDR & (1UL<<31))); /* Wait for Conversion end */

val = ((LPC_ADC->ADGDR >> 4) & 0xFFF); /* read converted value */

LPC_ADC->ADCR &= ~(7<<24); /* stop conversion */

return(val); /* result of A/D process */
}

// void InsertDynamicValues(void)
{
unsigned char *Key;
char NewKey[5];
unsigned int i;

if (TCPTxDataCount < 4) return; // there can't be any special string


Key = TCP_TX_BUF;

for (i = 0; i < (TCPTxDataCount - 3); i++)
{
if (*Key == 'A')
if (*(Key + 1) == 'D')
if (*(Key + 3) == '%')
switch (*(Key + 2))
{
case '8' : // "AD8%"?

{
adcValue = GetAD7Val(); // get AD value

sprintf(NewKey, "0x%03X", adcValue); // insert AD converter value

memcpy(Key, NewKey, 5);
break;
}
case '7' : // "AD7%"?

{
sprintf(NewKey, "%3u", (adcValue*100)/4024); // copy saved value from previous read

memcpy(Key, NewKey, 3);
break;
}
case '1' : // "AD1%"?

{
sprintf(NewKey, "%3u", ++pagecounter); // increment and insert page counter

memcpy(Key, NewKey, 3);
*(Key + 3) = ' ';
break;
}
}
Key++;
}
}

sadmonew
12-07-2012, 12:10
سلام مهندس:hi:
بله مثال خوبيه. اما قبول كنيد توضيح دادن در مورد اينكه هر دستور چه كاري انجام ميده. يه مقدار مشكله.
البته پيشنهاد ميكنم براي كار با شبكه از آي.سي مثل ENC28j60 استفاده كنيد.
برنامه هايي كه براي اين آي.سي نوشته شده قابل فهم تره. البته به اين معني نيست كه راحت باشه.
خودم با اين آيسي كار كردم. واقعا عالي كار ميكنه.

behnam6500
12-07-2012, 12:47
به این خوبی توضیح داده خود برنامه!

یه وب سروره با استفاده از اترنت میکرو!

روی پورت TCP_PORT_HTTP برنامه listen میکنه و در تابع You can see links before reply که در اینجا رخداد معرفی شده میاد وضعیت سرور رو چک میکنه! اگه ازتباط بود، بعد داده رو چک میکنه و ....

یه کم توضیحاتش رو بخون، دقیقن دستت میاد چی به چیه!