How to send image to client?
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: How to send image to client?
by Coccoliso ·
The example is a server application that waits on 8 opened listen sockets and when a client connects at one of them it answers: so can have 8 clients connected simultaneously.
You can decide that a socket can respond only to an HTTP GET request ( es: “/index.html” or “/image1.jpg” ) , but you can not divide the answer using multiple socket because only one of these is the connected socket that requires a single object at time.
You can resize only the buffer you use for the images in order to respond with a suitable buffer and decrease those respond html.
Keep in mind that in an embedded HTTP server application can never meet too many clients at the same time… the request/response must become one shot as possible and you must disconnect the socket after answering.
RE: How to send image to client?
by Coccoliso ·
I repeat…
you can not divide the answer using multiple socket because only one of these is the connected socket that requires a single object at time.
The browser not opens second sockets for a single request !!
A possibile solution is this :
Browser first load HTML page then with a second socket load myimage.png
RE: How to send image to client?
by Coccoliso ·
to be given: the W5500 can set all the socket for receiving the same port ( as in the example link)
In your case you need to give at one of them a greater buffer and force the client that requires the image to use it.
You can split the image into pieces and respond only ever on the socket that sent the request, but you have to send the block before the transmit buffer is overwritten (because it is a continuous loop)
So…
Read the TX buffer position by reg Sn_TX_WR0
Write into TX buffer until the size of the buffer - 1
Write buffer position in Sn_TX_WR0 ( previous value increased by block size )
Write Sn_CR register with Sn_CR_SEND value
Wait for it to execute the task by reading the register Sn_CR
Reading Sn_IR register for any timeout testing Sn_IR_SENDOK or Sn_IR_TIMEOUT condition ( and if Sn_IR_SENDOK all is done otherwise socket is losed so close it and abandons all )
if all ok, not close the socket but repeat everything to the next block
All this must be carried out in the browser timeout (almost always 30 seconds).
Pay attention to Sn_TX_WR0 : as the connection is almost certainly 0 but then it shifts when write between the different blocks.
Examples of code written in C ++ (for the DHCP and DNS) that are on the site contain all the functions for this purpose.
If you get on with the structured BASIC can have a look here http://www.firewing.info/pmwiki.php?n=FirewingUser.W5500 there is no a specific example of this but I have used the buffer asynchronously starting from the C ++ libraries above.
RE: How to send image to client?
by Coccoliso ·
If it says that it is difficult … but the multi thead on a device is incorrect.
I do not understand what can be attributed to the manufacturer with respect to libraries if they are specific to the MPU you use.
Clearly if you are using an Arduino it becomes easier ([url]https://github.com/Wiznet/WIZ_Ethernet_Library[/url]) but for other MPU you are forced to start from something that exists and you have a good knowledge of the MPU.
The YouTube link you are referring to is a client application Pachube for Arduino ([url]http://arduhome.jimdo.com/pachube/[/url]) and as far as I know the embedded send basic data format to the server that processes the request after your subscription.
The result you see is not generated by your MPU but by the server that made a rendering of your data.
RE: How to send image to client?
by Coccoliso ·
Hi Poligon,
since this thing intrigued me and like I said I had never tried to send breaking a higher content of the buffer in several parts I wanted to try it and my library PIC18 ( also this roughly translated from C ++) work correctly (tested up to 64K approximately with a 2K buffer and 1K data chunks ).
The sequence I used is as I wrote in this post [url]How to send image to client?] except that I was far from the last character of the buffer because even with this PIC18 I can not create a temporary buffer with more than 1024 bytes.
Try expanding blocks number decreasing the size of the data in the block thus not reaching the buffer overrun.
One important thing : I do not use the Send () but I read the current position of the TX buffer before writing, then write the block into TX Buffer, I tell to W5500 to send the TX Buffer, then I reread the position for each new block and repeat until the end of my buffer and then close the socket.
PS : I confirm up to 256 blocks of 1000 chars plus an html header of 27 bytes.
RE: How to send image to client?
by Coccoliso ·
As I told you my knowledge are the PIC18 / PIC24 and BASIC.
Since it is from source C ++ you are using that I am started for my library we can easily return …
The Send() function performs checks on the transmit buffers that prevent the overrun but inside are some arguments that interest you to make a “multipart” transfer.
Original Send() function :
… so from Send() function you can use :
The rest are just controls on buffer overrun, but that is under control if you manage as will I had said in previous posts.
) there are no problems talking about it or extract what you need.
If you can read BASIC sources ( here [url]How to send image to client?]