This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:software:homelab:library:module:ethernet [2012/05/30 16:54] – eero.valjaots | en:software:homelab:library:module:ethernet [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Ethernet ====== | ====== Ethernet ====== | ||
| - | <note important> | + | |
| //Necessary knowledge: [HW] [[en: | //Necessary knowledge: [HW] [[en: | ||
| Line 28: | Line 28: | ||
| * //maxlen// - maximum allowed data buffer size. | * //maxlen// - maximum allowed data buffer size. | ||
| * //*buffer// - array where to save received data for further operations. | * //*buffer// - array where to save received data for further operations. | ||
| - | * If the packet has arrived, returns the length of the received packet in baits and in opposite case returns 0. | + | * If the packet has arrived, returns the length of the received packet in bytes and in opposite case returns 0. |
| * **// | * **// | ||
| Line 34: | Line 34: | ||
| Parameters: | Parameters: | ||
| * //*buf// - data array to analyze. | * //*buf// - data array to analyze. | ||
| - | * //plen// - length of received packet in baits. | + | * //plen// - length of received packet in bytes. |
| * Tagastab URL-i esimese tähemärgi aadressi. Kui URL on tühi, siis tagastab 0. | * Tagastab URL-i esimese tähemärgi aadressi. Kui URL on tühi, siis tagastab 0. | ||
| * Returns the address of the first char in URL. If URL is empty, it will return 0. | * Returns the address of the first char in URL. If URL is empty, it will return 0. | ||
| Line 54: | Line 54: | ||
| - | ~~PB~~ | + | < |
| ===== Example ===== | ===== Example ===== | ||
| Line 102: | Line 102: | ||
| pktlen=ethernet_get_packet(BUFFER_SIZE, | pktlen=ethernet_get_packet(BUFFER_SIZE, | ||
| - | // Performs packet preconditioning and answer to " | + | // Performs packet preconditioning and answer to " |
| + | // Returns packet URL. | ||
| gPlen=ethernet_analyse_packet(buf, | gPlen=ethernet_analyse_packet(buf, | ||
| Line 108: | Line 109: | ||
| if (gPlen!=0) | if (gPlen!=0) | ||
| { | { | ||
| - | // Load URL address part into " | + | // Load URL address part into " |
| + | // The first 4 digits are IP address numbers. | ||
| str = (char *)& | str = (char *)& | ||
| Line 156: | Line 158: | ||
| // Load webpage header | // Load webpage header | ||
| - | plen=ethernet_load_data(buf, | + | plen=ethernet_load_data(buf, |
| + | (" | ||
| | | ||
| - | | + | plen=ethernet_load_data(buf, |
| // if LED is off, display it | // if LED is off, display it | ||
| if (on_off) | if (on_off) | ||
| { | { | ||
| - | plen=ethernet_load_data(buf, | + | |
| } | } | ||
| // if LED is on | // if LED is on | ||
| else | else | ||
| { | { | ||
| - | plen=ethernet_load_data(buf, | + | |
| } | } | ||
| // Lae " | // Lae " | ||
| - | plen=ethernet_load_data(buf, | + | plen=ethernet_load_data(buf, |
| + | | ||
| | | ||
| // Load the button for LED condition change. | // Load the button for LED condition change. | ||
| Line 190: | Line 194: | ||
| </ | </ | ||
| - | |||