Shop OBEX P1 Docs P2 Docs Learn Events
Spinneret and SHT11 - Page 2 — Parallax Forums

Spinneret and SHT11

2»

Comments

  • JAGOJAGO Posts: 49
    edited 2011-10-22 07:38
    Ok, understand i'll try to do it. And you have reason the method already create a new log if the file "A" not exist, great idea!

    Many thanks mike, greetings.
  • Mike GMike G Posts: 2,702
    edited 2011-10-22 07:50
    The "A" is append.
      if(FileExists(@logfile))
        SDCard.openFile(@logfile, "A")
      else
        SDCard.newFile(@logfile)
    

    The FileExists() method is want checks if the file exists. All you have to do is modify the @logfile. I made a mistake though... you can not name the file logYYMMDD as that is 9 characters, 8 characters is the MAX. Name the file something like LGYYMMDD.txt.
  • JAGOJAGO Posts: 49
    edited 2011-10-23 17:51
    Hi mike,

    Understand the logic, i'm trying to modify the code for generate a new log.txt every day, do you have any example code for append the date to file name?? i'm trying but append more than 8 characters and not asigned the name... i'll continue trying.

    greetings.
  • Mike GMike G Posts: 2,702
    edited 2011-10-23 18:33
    JAGO, write characters to the the @logfile buffer. The first two characters can be LG the 6 characters that follow are year/month/day (YYMMDD).
    logfile     byte  "lgYYMMDD.txt"
    
    JAGO wrote:
    do you have any example code for append the date to file name
    All you have to do is fill in 6 characters; YYMMDD. There is an example of writing a date to RAM in HTTPServer. Remember, the file name must follow the 8.3 naming convention.
  • JAGOJAGO Posts: 49
    edited 2011-10-23 19:43
    Hi mike,

    i do it this and works fine, i can write in the @logfile buffer, but i meant to do it automatically in base to @httpdate, i can do it manually but i think will be great if could be automally in base to the RTC date, understand the idea? I'll continue with my experiments.

    Greetings, mike.
  • Mike GMike G Posts: 2,702
    edited 2011-10-23 20:28
    i do it this and works fine, i can write in the @logfile buffer, but i meant to do it automatically in base to @httpdate, i can do it manually but i think will be great if could be automally in base to the RTC date, understand the idea? I'll continue with my experiments.
    I understand the idea... you have all the code required to dynamically generate a file name with the current date. Look at the Response.spin object. The response object handles browser cache which requires the current date and time.
  • JAGOJAGO Posts: 49
    edited 2011-10-23 20:39
    Ok, understand... I'll check the code, thanks for all mike.
  • JAGOJAGO Posts: 49
    edited 2011-10-24 15:03
    Hi,

    Today continue with my spinneret and i can generate automatically a TXT file in base to the RTC date, so now every day the software generate a new log.txt with the date reference and the data will not blend, great! but i have a new doubt, be possible indicate how often want save data in the log.txt, in this moment i save the data when i call the method but i would like do it every 1 minute automatically, do you have any idea??

    thanks mike.
  • Mike GMike G Posts: 2,702
    edited 2011-10-24 15:53
    Start a new cog that runs the method(s) every 60 seconds.
  • JAGOJAGO Posts: 49
    edited 2011-10-24 16:11
    Thanks mike,

    sounds Easy XD... The command for Start a new cog is @cognew rigth? I try to do it.
    Do you have any example for do it something similar?

    Thanks
  • Mike GMike G Posts: 2,702
    edited 2011-10-24 16:30
    Yes, there is an example in HTTPServer of starting a new process in a COG. Plus there are examples in the Propeller Manual. You'll need to use the system clock (CNT) to figure out when 60 seconds has past.
  • JAGOJAGO Posts: 49
    edited 2011-10-24 16:46
    Ok, understand the idea. One doubt mor
  • Mike GMike G Posts: 2,702
    edited 2011-10-24 17:12
    HTTPServer uses 6 COGs. You can always add the timer logic to the Main() HTTP Service to conserve COGs.
  • JAGOJAGO Posts: 49
    edited 2011-10-24 17:43
    Ok, so the propeller is almost in the max capacity or not? Other cuesti
  • Mike GMike G Posts: 2,702
    edited 2011-10-24 18:59
    The Propeller has 8 COGs. This information is openly published in the Propeller manual. I'd initialize the a new COG process in the Initialize method of HTTPServer, right after the StatusMonitor starts.
    cognew(StatusMonitor, @StackSpace)
    
  • JAGOJAGO Posts: 49
    edited 2011-10-25 07:51
    Hi mike,

    Ok, understand. i'm learning about the cognew command for do it. one cuestion, in the command cognew(statusmonitor,@stackspace) understand that cognew enable other cog for parallel processing and the statusmonitor is a PRI function in the httpserver code, this funtion check the sockets of the W5100 rigth?, but what is the function of @stackspace??

    greetings...
  • Mike GMike G Posts: 2,702
    edited 2011-10-25 15:06
    To provide the process with an operating stack. This information is openly published in the Propeller manual in the cognew section.
  • JAGOJAGO Posts: 49
    edited 2011-10-25 18:15
    hi mike,

    ok, understand... today learning about the cognew command and now i can execute the appendlog method every 60 seconds using a new cog and works fine...now i'm checking the webpage for control led (i/o 23) and i would like add a gif image for represent the status of led on/off, i check the code and found the line:

    <p>status led: <span id="placeholder">
    </span></p>

    in this line change the status with the "placeholder" variable when i click ON "placeholder" take a ON status and when click OFF place holder take a OFF status and print in my web page, is correct?? well, i do it a code for ask for the status of "placeholder" and in base to his status i'll change a gif image, this is the code :

    <p>status led: <span id="placeholder">
    </span></p>

    <script language="javascript" type="application/javascript">

    switch(placeholder)
    {
    case "on":

    document.write("<h2>on</h2>");
    document.write('<img src="on.gif"/>');
    break
    case "off":

    document.write("<h2>off</h2>");
    document.write('<img src="off.gif"/>');
    break

    }
    </script>

    the javascript code works when i stablish manually the status ex: placeholder="on" this is inside of the javascript code but when excute the code for take automatically the status of "placeholder" not work..... but in the line span id change the status to "on" and "off", what do you think? i'm in the correct way for do it or i'm in the wrong way??

    thanks for all...
  • Mike GMike G Posts: 2,702
    edited 2011-10-26 07:24
    The JavaScript is inline and only runs when the page loads. You must set the placeholder variable above the switch statement. The <span id="placeholder"></span> is not in any way connected to the switch.

    If you are trying to use AJAX, then you must drop the inline document.write method and use document.getElementById. getElementByID allows dynamic updates of the Document Object Model (DOM) without reloading the web page. Examples, can be found in the tutorial.
    http://spinneret.servebeer.com:5000/services/ajaxled.htm
    http://spinneret.servebeer.com:5000/services/xmltime.htm

    HTML/DOM tutorial
    http://www.w3schools.com/htmldom/default.asp
Sign In or Register to comment.