Spinneret SD Card usage problem- help please?
Rforbes
Posts: 281
Hey all,
I'm trying to understand the HTTPServer object better, and I'm definitely making some headway. But I am getting myself stumped here.
Where I've listed this <========== in the code is my question. Is this variable equal to 0 when no one is trying to get or post to the server?
The reason I'm asking, is because I need to run a method in another cog that uses the SDcard to write and append static *.xml files. I'm trying to think of a way to ensure that I don't try to use any of the sdcard methods from two cogs at once. I did that today and it made some really interesting files and folders on the sdcard... heh. Had to format it and start over.
So, if fifosocket is equal to 0 when there is no traffic, I can use that as a means to tell my other cog that it's ok to go ahead and write or append files to the sd card. Or at least it's ok to start at that instant.
I hope this question makes sense.
Thanks in advance!
Robert
I'm trying to understand the HTTPServer object better, and I'm definitely making some headway. But I am getting myself stumped here.
PUB Main | packetSize, id, i, reset, j, temp '' HTTP Service GetSntp(3) repeat repeat until fifoSocket == 0 <================================== does this = 0 when there are no requests to serve up a file? SDCard.changeDirectory(@approot) bytefill(@rxdata, 0, RxTx_BUFFER) if(debug) 'pst..str(string(13, "----- Start of Request----------------------------",13)) QueueDump else pause(DELAY) ' Pop the next socket handle id := DequeueSocket if(id < 0) 'pst..str(string(13,"Id < 0")) 'pst..dec(id) 'pst..char(13) nextPUB Main | packetSize, id, i, reset, j, temp
Where I've listed this <========== in the code is my question. Is this variable equal to 0 when no one is trying to get or post to the server?
The reason I'm asking, is because I need to run a method in another cog that uses the SDcard to write and append static *.xml files. I'm trying to think of a way to ensure that I don't try to use any of the sdcard methods from two cogs at once. I did that today and it made some really interesting files and folders on the sdcard... heh. Had to format it and start over.
So, if fifosocket is equal to 0 when there is no traffic, I can use that as a means to tell my other cog that it's ok to go ahead and write or append files to the sd card. Or at least it's ok to start at that instant.
I hope this question makes sense.
Thanks in advance!
Robert
Comments
You'll have to halt the sockets. The following snippet of code will save the run-time TCP socket IDs and halt socket id. If you wanted to halt all 4 sockets you would have to invoke SetTcpSocketMaskById four times. Once for each socket.
On SD IO completion, we'll have to put the a single socket back in operation.
Keep in mind that halting all the sockets mean HTTP requests can be missed.
By doing this, if I try to call up a web page when I'm running this Logdata method- will the webserver just wait and then process the request once I reset the socket? If I used it for all 4 sockets that is (instead of just one as shown)
But this still seems like it won't really work exactly right. I think I'd still need to do something similar in the datalog method to ensure it doesn't start writing a file at the instant the dispatcher method is fetching one to serve up.
Keep in mind the data log process will block socket Rx processing. There are 4 Rx socket buffers. Once the 4 Rx buffers are in use any subsequent client requests can produce unexpected requests depending on the persistence of the client.