Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

+TCP HTTP CGI / REST

Posted by miclam on March 23, 2017

Like Michael here https://sourceforge.net/p/freertos/discussion/382005/thread/72bd7781/ I also need a way to deliver data as dynamically created JSON objects and to embed placeholders in HTML files. uIP had CGI routines for that.

Basically what happend there was, that if a requested file had a specific ending (.shtml), instead of just serving the file as-is, it was scanned for placeholders like %! foo. Content up to the placeholder was send, then the script associated with the placeholder was executed and the return was send, then the rest of the file was processed.

I am planning to implement a similar logic, since it should be easy to call FreeRTOS_send() multiple times.

I am aware of the ipconfigHTTPHASHANDLEREQUESTHOOK, which will be usefull to analyse GET parameters to answer requests like /user.json?id=12.

As soon as I have some code I will append it here, but I'm already up for comments and feedback.


+TCP HTTP CGI / REST

Posted by heinbali01 on April 22, 2017

Hi Michael, sorry for thinking so long about a proper answer to your post.

When I hear "CGI", I've always thought that you need an OS which can at least run a script or a program. It doesn't sound like FreeRTOS, which is running tasks, not programs. And 'scripts', yes, you can interpret scripts.

I understand the need for flexible HTML code. What we decided, well not "we" but the JS (JQuery) programmers that I work with, is to make extensive use of the statement:

~~~ $('#id').html( ); ~~~

That is a different way of creating flexible HTML code.

The actual <html code> is often the result of a JSON request to an HTML server. And this request is indeed handled by the application hook ( with ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK enabled ).

Only requests with a certain characters (usually a '?') will be forwarded to the application. All other requests are about retrieving files.

In some project I'm showing the properties of a sound-limiter, gain, bass, treble, and also the actual (measured) sound pressure. There is a constant polling of these properties and they're shown in a browser with e.g.:

~~~ $('#idvolume').html(settings.volume); $('#idbass').html(settings.bass); $('#idsoundpressure').html(settings.spl); ~~~

The advantage of this approach is more simplicity at the embedded side. It just has to answer simple questions about settings and measurements. And also it gets commands of course, to change the settings.

Browsers are normally running on powerful CPU's with lots of memory. Let them do more work to unload our small cheap MCU's :-)

As soon as I have some code I will append it here, but I'm already up for comments and feedback.

Please do, post it. Many people are looking for workable solutions. It is not original to say, but there are many ways to Rome. Regards.


+TCP HTTP CGI / REST

Posted by glenenglish on April 23, 2017

Hi Michael I have a simple web functionality for serving JSON files the original HTTP server was built from bits I found from Lwip HTTP and Freertos http, and file system , it also hamdles POST.

FreeRTOS-PlusprotocolsHTTP I build the FS for the http server with a linux script into fsdata.c.

It builds and decodes the JSON files on the fly.

jsonproc.c

and also serves a .dat file for other purposes. it serves files from the flash fs (include file) , and if the extension is .json, it goes and builds the json files on the fly from hot data,

I also have libs for programming flash for NVs , and also for configuraing a xilinx fpga

in /web/fs you will find my web page sources . have a look at ipsetup.htm etc

feel free to contact me direct -glen

Attachments

rev1.7z (309882 bytes)


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS