WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Busybox-httpd SVG  (Read 4377 times)

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Busybox-httpd SVG
« on: January 19, 2015, 12:18:38 AM »
Been using Busybox-httpd as my webserver.
Want to add a shell script generated SVG temperature plot file.

It looks like SVG is not a MIME type supported in Busybox-httpd.
Can it be added or does it need to be recompiled?

Or else convert .svg to .png, yikes.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10737
Re: Busybox-httpd SVG
« Reply #1 on: January 19, 2015, 01:29:41 AM »
You can add mimetypes in its (runtime) config file. See httpd.c in busybox source for an example.
The only barriers that can stop you are the ones you create yourself.

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #2 on: January 19, 2015, 06:10:57 PM »
Added this line to the httpd.conf file

.svg:image/svg+xml

Made no difference after rebooting.
Chrome auto downloads the SVG file
And Firefox says I need a plugin.

On Windows viewing the index.html file works in Chrome and Firefox.
The difference between serving the file and viewing a index.html file with .svg link?

SVG is just text, so serving it should be easy, it just needs to tell the other end (browser) it is an image.



Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #3 on: January 19, 2015, 09:07:45 PM »
No idea why it is not  serving external SVG image file properly, has no trouble with .png.

Now doing inline SVG in the shell script that generates the HTML index file, it works but it is ugly.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10737
Re: Busybox-httpd SVG
« Reply #4 on: January 20, 2015, 12:21:08 AM »
Did you check the mimetype was applied? ie wget -S -O /dev/null localhost/foo.svg
The only barriers that can stop you are the ones you create yourself.

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #5 on: January 20, 2015, 12:48:00 AM »
Not connected to the net, so wget won't work.

Raspberry Pi's firewalled by the Uni :(

Just got 1st plots on the web page.
done as inline svg generated by shell scripts and spliced into the index.html file.
Takes about 10 secs but I only need 60 sec update.


Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7181
    • My Community Forum
Re: Busybox-httpd SVG
« Reply #6 on: January 20, 2015, 12:59:59 AM »
You can convert image to png/jpg also if it fits better
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #7 on: January 20, 2015, 04:43:42 PM »
SVG's are easy to make from shell scripts, just text files.
Nearly all browsers support SVG, some even with hardware acceleration.
Will need a conversion program to convert to png/jpg, extra programs then required.

Trying to do everything with just Linux kernel and busybox.
The minimalist IoT setup, but at HTML5 standard.

2 reasons..
I get to learn Linux at nearly the lowest level and smallest OS size.
Future IoT stuff is easier to do if libraries/programs are not needed when porting to other hardware/CPUs.

Linux is/will be every where.
We use Raspberry Pi's because they are cheaper and with more stuff than any other CPU board including Arduino.

Once it all works in shell then C compiled code can be done to make it go faster.

Could do it all in Raspbian and apt-get the extra programs but I don't learn much and I end up having to support a 4GB OS.
Did that to start with 2yrs ago, it is still working luckily.





Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 376
Re: Busybox-httpd SVG
« Reply #8 on: January 20, 2015, 10:51:31 PM »
hi gavinmc42,

I like your minimalist approach and wanting to do temperature graphs in the future thought I'd test svg on piCorePlayer.

I added .svg:image/svg+xml to http.conf

Stopped web server. Started it again with:

/usr/local/sbin/httpd -h /home/tc/www -c /home/tc/http.conf

svg file displayed in all web browsers I tried on Windows 7 PC and iPad.

regards
Greg

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #9 on: January 21, 2015, 06:17:49 PM »
Hi Greg,

Will retry http.conf to get httpd serving .svg files.
Need to add some code to save previous days plots as  *.svg.
Then user can view/download earlier plots.

HTML Inline SVG graphing is possible, take about 10 secs to generate plots using only every 5 mins of data.
Much longer plotting every minute.
Compiling a small C program would speed it up.

I have to use sed alot.
Starting with a basic html file called index.txt,  sed looks for lines with "insertdatahere" and replaces it with the formatted svg line plot data and copies it to index.html.

Just found my 1st bug, HTML inline SVG does not like NULL values:(
Looks like it's due to i2c sensor read error.

Inline SVG on a browser is fast, png screen dump is 57kB but HTML page with inline SVG is 13kB.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 376
Re: Busybox-httpd SVG
« Reply #10 on: January 21, 2015, 10:05:49 PM »
hi gavinmc42,

Nice plot...first half.

I'll have to remember this thread when I get around to generate some temperature plots.

I have always used perl and GNUplot in the past. So shell and svg will be a new challenge.

regards
Greg

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: Busybox-httpd SVG
« Reply #11 on: January 22, 2015, 12:15:16 AM »
Yep, that plot is what happens when someone defrosts while you are debugging :)

SVG reminds me of the old HP-GL plotter language, pen up, move to x,y,  pen down, line to x1,y1

Now trying to figure out Busybox-httpd CGI scripts, back to the Corebook.pdf
Got nice HTML5 spinner boxes to set temperature alarm levels.
Now trying to figure out how to get the values in the browser back to the RPi and written into the config.ini file.
I think CGI scripts is one way to do it?
That temp plot is pretty much my coding progress too - up, down, crash.

Someone is working on putting i2c-tools into busybox, when that works I can toss i2c-tools.tcz.


Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10737
Re: Busybox-httpd SVG
« Reply #12 on: January 22, 2015, 01:16:35 AM »
Yeah, the easiest is to put the element inside a form with "method=get action=myscript.sh". Then in myscript you will have all form elements in the $QUERY_STRING variable.

For example, it could have "name=matt&value=50", without quotes.
The only barriers that can stop you are the ones you create yourself.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7181
    • My Community Forum
Re: Busybox-httpd SVG
« Reply #13 on: January 22, 2015, 02:05:17 AM »
Someone is working on putting i2c-tools into busybox, when that works I can toss i2c-tools.tcz.

i2c-tools.tcz already in the repo. It is a small 66k extension, which depends on perl5.tcz However you can check whether perl is need for your application and if not you can drop it. Also in a specific case you can use a smal wrapper to interface i2c-tools.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 376
Re: Busybox-httpd SVG
« Reply #14 on: January 22, 2015, 02:05:51 AM »
Yep, that plot is what happens when someone defrosts while you are debugging :)

SVG reminds me of the old HP-GL plotter language, pen up, move to x,y,  pen down, line to x1,y1

Now trying to figure out Busybox-httpd CGI scripts, back to the Corebook.pdf
Got nice HTML5 spinner boxes to set temperature alarm levels.
Now trying to figure out how to get the values in the browser back to the RPi and written into the config.ini file.
I think CGI scripts is one way to do it?
That temp plot is pretty much my coding progress too - up, down, crash.

Someone is working on putting i2c-tools into busybox, when that works I can toss i2c-tools.tcz.

Hi gavinmc42,

I don't know if you have ever looked at piCorePlayer.

Steen and I have based the gui interface all on busybox-http, shell, shell cgi and html5 only (plus a little javascript). We pass variables around via the $QUERY_STRING as suggested by curaga.

If you get stuck, I think we could help.

I like to design and build DIY amps, and wanted to include a Raspberry Pi into my prototype amps as a temperature monitoring device to track output device and heatsink temperatures. I came across Steen's piCorePlayer and realised Steen had already done all the hard work of getting piCore and a nice web interface going. I did get side tracked a little and would like to get back to my original goal.

regards
Greg