Posts by Richard

    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!

    We are using the standard C++ try..catch exception handling with the /GX compiler switch enabled.


    However, exceptions generated by the CFile seem to be using the C/MFC exception handler TRY..CATCH..END_CATCH.


    Is this exception method for MFC functions defined by the kernel build, or can we change it?


    We can use either method, but would like to be consistent in its usage.