Passing Value from C++ to Javascript -


i have c++ file reads values sensor , want display values on website dynamically. im looking way pass these values(integers) cpp file javascript displays them on site.

my first, simple try write values js file variables every second cpp script. js uses file source , displays variables on site:

cpp:

fprintf(file, "var mx=%d, my=%d, mz=%d, ax=%d, ay=%d, az=%d, gx=%d, gy=%d, gz=%d;\n",     imu.raw_m[0], imu.raw_m[1], imu.raw_m[2],       // m = magnetometer     imu.raw_a[0], imu.raw_a[1], imu.raw_a[2],       // = accelerometer     imu.raw_g[0], imu.raw_g[1], imu.raw_g[2]        // g = gyroscope ); 

html/js:

<script src="./imu.js" type="text/javascript"></script> 

the problem of course, need refresh page time, because imu.js file cached website.

i'd rather have way directly pass integers cpp file js script. read json or googles v8 script. i'd hear suggestions first.

by way, im running on raspi, if important.

thanks help

edit:

i'm goning try mysql database, in cpp file writes data sensor connector/c++ http://dev.mysql.com/doc/connector-cpp/en/ , website reads them.

you compile c++ code node.js plugin, can register javascript function plugin c++ calls when updates value. way can pass values directly c++ javascript in managed , controlled way.

node.js has added benefit of being able host webpage , websocket , http stuff can pain in c++.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -