View previous topic :: View next topic |
Author |
Message |
anlpereira
Joined: 20 Sep 2013 Posts: 3
|
CCS Ethernet Stack How to send images. |
Posted: Mon Sep 23, 2013 2:57 pm |
|
|
Hi everyone, I've implemented the CCS TCP/IP stack in my PIC18F97J60 and it is working good, I've done some modifications. But now I would like to send some pictures from my embedded server. Like for example, I have a picture of a lamp turned on or off, when I click it the picture that is showed is one and vice-versa.
How could I implement this feature? I know that there are some softwares that I can convert a .bmp or .gif to 'C', it generates an array and I can embed it the in flash memory as a constant, I've used this before. So, how could I send it through my tcp connection? |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Mon Sep 23, 2013 4:51 pm |
|
|
So if the pic is the server, it should respond to a GET issued by the browser.
The browser also supplies the name of the file in the GET command. Next the pic has to access the file and send it. Now files are often big relative to the pic storage especially images. Often this means extra storage is needed like an SD card. The SD card requires the pic to act as a master and retrieve the file. Since images are often created by a PC. The PC file system will often have formatted the SD card ( Ex FAT ) in that case the pic must also be able to navigate the FAT structure. |
|
|
anlpereira
Joined: 20 Sep 2013 Posts: 3
|
|
Posted: Mon Sep 23, 2013 7:28 pm |
|
|
I know the server will answer the GET commands, but I would like to know where I can insert the picture in the code if I already have it in C code. I know I have small space in memory but the picture is very small too. |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Tue Sep 24, 2013 3:31 am |
|
|
If the file in a constant array was originally say a LAMP_ON.bmp then your PIC code on receiving a GET for file LAMP_ON.bmp would write the bytes in your constant array into TCPIP packets and dispatch them. A TCPIP packet has a limited size about 1400 byes so several packets will often be needed.
The browser will present a TCPIP window for flow control....the stack probably handles this already but if not it is unlikely the pic will overflow the window ( typically it is 8k or more) before the browser empties it.
Now if the pic knows the status of the lamp and the browser doesn't then have the browser just via get request that lamp.bmp be sent.
The pic just after it decodes the packet with GET LAMP.bmp reads from the constant array in PIC flash either the LAMP_ON.bmp or the LAMP_OFF.bmp depending on the lamp status and constructs the TCPIP packets to dispatch to the browser.
You seem as if you know what you are doing and are aware of the limitations so this should be straight forward unless there is something your are not explaining. |
|
|
|