I need your idea

  • Hello all,


    I have an application running in NetDCU8. This application communicates with other devices via I2C. Also NetDCU has "Web Server".
    I want to show to user who connected to NetDCU via browser, "ONLINE" status of devices those connected to NetDCU and communicate with main application.


    Which way is the best way to do that?
    I'm very appreciated if somebody give me an idea.
    Tank you very much in advance

  • You need a C program to read the I2C port, a web server, some web pages and then the problem is how to glue them together.


    There's two methods I have used, both are not particularily elegant.


    Method 1: Simple, constrictive and slow.


    1/ Create a small C program/s which returns the status of the device.


    2/ Write a perl/python/etc (whatever script language is available for use with the web server) which will execute the C program, read the return value and use it in a conditional clause to insert html into the web page.


    3/ Create a web page which contains a directive to execute the above script.


    So, the result is:


    The operator requests the web page from your web server. The web page is parsed by the server and it encounters the script directive, which is then executed and the output of the script is inserted inline into the web page. The script executes the C program which reads the I2C port and returns a value.


    However, All this processing takes a long time to complete and can only return a limited amount of data. So the next, more complex, solution is (using linux/apache):


    Download the apache source code. Write an additional parser within apache modules which provides a link to your main application in C. When a web page is requested from a client, the url is read and parsed by the web server. within the parser (as a seperate module) you insert your own bespoke code. For example, if the parser reads a character sequence which means "read input port $52", it will then remove this from the parsing stream and call your main 'C' application via a shared memory/common api/interprocess message queue etc. The data is returned back in a similar method, and is inserted into the output stream, which can be further formatted by subsequent filters.


    This method is fast but complex.


    A Full description of both processes, including examples, are detailed in the book:


    "Writing Apache Modules with Perl and C: Customizing Your Web Server (Paperback)"
    by Lincoln D. Stein (Author), Doug MacEachern (Author) 978-1565925670


    Once you have the page, you will need to refresh it periodically to detect changes. This does make it feel clunky and unresponsive.


    Good luck!

  • I think the best solution is to write a ISAPI ectension for the WinCE HTTP server. You can find some samples in the web. The only problem with this is limited debugging support.


    Regards
    Holger

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,
    The ISAPI extension is only responsible for generating HTML code.
    Access to I2C bus (scanning devices) will be down in another application. This application opens i.e. a memory mapped file and stores information about I2C bus in this file. ISAPI extension can read information from this file. Additionally you can trigger ISAPI extension by named event about changes in this file.


    Regards
    Holger

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Dear Mr. Holger
    Thank you for your reply.
    you mean I can use shared memory.
    Because using shared memory needs some handshaking for blocking read and write and two process shold not be access to that in same time.


    My question is can I access to shared memory inside the ISAPI?


    Thanks

  • Hello,
    When you use a memory mapped file it should be no problem to open it from ISAPI extension.
    Regards
    Holger

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • the simplest, but perhaps not really the best and flexible way is to write a small c-program that gets executed periodicaly and aquires the values from i2c and then puts them directly in the html-output file or another file thats readen by java-script or someting like that?!


    mfg andreas

  • Hello,
    As Mr. Holger told, I implemented two process. One of them (exe) makes "Memory Mapped File" and copy data to MMF and another (ISAPI-DLL) reads MMF and show data.


    Now my question is about synchronization.
    1) if the first process has pariority higher than the second, maybe the second process could not access to MMF to read.


    2) what happend if the socond prossess is reading and the first process want to write?
    in this situation I think the reader process continue to reading becuse priority conversion occurred and the writer process must wait for the reader process until release memory and writer waste time.
    In my application, writing to memory (the first one) is a part of main process and I can not waste time for this thread.
    What can I do?


    3) how can I detect the resource that the writer needs is used by the reader and cancel writing to avoid waste time?


    I'm very appreciated if somebody send me answer back.
    Thanks

  • Hello,
    You can use a named mutex to synchronize access.
    Regards
    Holger

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.