[Gambas-user] A couple of questions about building web / cgi applications

Bruce Cunningham bcunningham at ...3336...
Fri Feb 13 21:35:13 CET 2015


Caveat,

Thanks for the info.  

I'm a little concerned about using a "disk" based database because the disk is flash, which has a limited number of write cycles.  Even with wear-leveling, I would eventually kill parts of the flash.  I don't want these things dropping dead in the field after a year or so...

I was considering something like named pipes, but I'm a little unclear about how Linux actually handles them.  I thought I saw a mention that they are managed via temporary files within the file system, and that would defeat the whole idea of not writing to disk.

I know how to do interprocess communication in Windows, but not in Linux with Gambas.

Bruce

Bruce Cunningham
bcunningham at ...3336...


-----Original Message-----
From: Caveat [mailto:Gambas at ...1950...] 
Sent: Friday, February 13, 2015 11:36 AM
To: gambas-user at lists.sourceforge.net
Subject: Re: [Gambas-user] A couple of questions about building web / cgi applications

If you're going to use a database to communicate between 2 separate programs, be sure to set the transaction isolation to READ-COMITTED (good for MySQL, ymmv), otherwise you won't see updates made by another process which can lead to some frustrating and confusing mismatches between what you think should be read from the database and what actually gets read!

You may also want to look at in-memory databases, if you don't need the sensor data to be persistent.  H2: 
http://www.h2database.com/html/main.html and JavaDB: 
http://docs.oracle.com/javadb/10.8.3.0/getstart/index.html
might be worth a look.  You could always use a regular database for the less volatile data, like user settings etc. and I imagine the inter-process communication would be easier to set up using a normal disk-based database.

The architecture is sound, I use a raspberry pi in a similar way to control my central heating.  There's a python script running all the time checking for interrupts so you can hit a button on the pi (PiFace board added) to, for example, force the heating on.  The python script reads from the MySQL db to see what temperature it should be aiming for, and reads a usb thermometer to see what the temperature actually is.  
There's a web interface written in php with big friendly buttons to force the heating on or off, and a nice display of the current temperature and the target temperature, and an indication of the state of the heating (on or off).  Inter-process communication is all done via the heating database in MySQL (with tx-isolation as above!).

Sorry, kind of realised at the end this is a little off-topic for most of the Gambas list, what if I promise to rewrite my web-interface in Gambas CGI? :-)

Kind regards,
Caveat


On 13/02/15 09:42, Rolf-Werner Eilert wrote:
>
>
> Am 12.02.2015 19:09, schrieb Bruce Cunningham:
>> I'm looking for some advice and maybe some code examples for a 
>> project I'm starting.  I'm building an embedded device with an ARM 
>> based System-On-Module (similar to an Rpi, but in an sodimm form 
>> factor).
>>
>> Thanks to some great help from members of this mailing list, I have 
>> successfully compiled Gambas for the SOM.  The device will have a 
>> "main" GUI application that handles the user interface and all of the 
>> control logic.  However, it will also have a web interface for remote 
>> access to some of the control settings.
>>
>> Here are my questions:
>>
>> 1) Does anyone have any code examples for CGI applications in Gambas?  
>> I know there is an option to use the Gambas interpreter to build 
>> ASP-like pages, but I would rather the web code be in compiled into a 
>> CGI module instead (for security reasons).  I've built CGI 
>> applications in VB6, so I have a fairly good understanding how CGI 
>> work in general.  I've read the Gambas docs on CGI, but I still don't 
>> quite understand it.
>>
>> 2) What is the easiest way to exchange data (variables and arrays) 
>> between the CGI module, and the main application?  Using a file on 
>> disk is not a great option, since the device will be using flash for 
>> the file system, and these values will be changing several times a 
>> second.  That will kill the flash very quickly.
>>
>> Thanks,
>>
>> Bruce Cunningham
>> bcunningham at ...3336...<mailto:bcunningham at ...3336...>
>
> Hi Bruce,
>
> although I see your point, I don't see where there is a difference 
> between a gb.web app and an all-in-one app (apart from the ASP-like 
> pages to be stored separately). BUT: I once made some projects this 
> way, back in the times of Gambas2, so here is what I have (comments 
> are in German, and scarce, so if you have any questions...)
>
> One of the projects (umfragen) is still publicly running on our 
> website at 
> http://www.eilert-sprachen.de/cgi-bin/Umfragen.gambas?Selbsttest.data
>
> Take a look at those SUBs which start with "schreibe" (write), that's 
> the core of it.
>
> Hope it helps!
>
> Regards
> Rolf
>
>
>
> ----------------------------------------------------------------------
> -------- Dive into the World of Parallel Programming. The Go Parallel 
> Website, sponsored by Intel and developed in partnership with Slashdot 
> Media, is your hub for all things parallel software development, from 
> weekly thought leadership blogs to news, videos, case studies, 
> tutorials and more. Take a look and join the conversation now. 
> http://goparallel.sourceforge.net/
>
>
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list