So, finally got the GPS and sensors working as webserver on Raspberry

On a sunny day (Wed, 06 May 2015 16:08:30 +0100) it happened John Devereux wrote in :

Netcat makes a great server too: index.html must be a real html file: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html; } | nc -l -p 81; sleep 1 ; done

(stop with ctrl C, that is why the sleep statement is included) start your browser

127.0.0.1:81

See:

formatting link

There are many _different_ versions of netcat, so the command line flags may be different for yours. netcat -h should show those.

You can commi nuke aid bypassing all these collective sites by running one netcat as server and one as client.

Reply to
Jan Panteltje
Loading thread data ...

I use the terms computah, raidio, Ummm..., guess(tm), and other mutilations of the English language as an easy way to find my writings with Google. It's much like the custom fonts favored by many architects. It's also somewhat useful for finding parts and pieces of my rants that were plagiarized by someone. I've been doing that since college in various forms. To the best of my knowledge, I originated the term, which has become all too common:

The origin of my use of the word "computah" was compliments of a friend from the US south, that had difficulties pronouncing the trailing "r" in computer, and would substitute "ah" instead. Previously, there were also some discussions at Ma Bell over whether the required separation of computing from telephone would require a different spelling of the word computer. I proposed computah in jest, which apparently stuck in a few areas.

Also, I'm not trying to be funny. I am funny.

--
Jeff Liebermann     jeffl@cruzio.com 
150 Felker St #D    http://www.LearnByDestroying.com 
Santa Cruz CA 95060 http://802.11junk.com 
Skype: JeffLiebermann     AE6KS    831-336-2558
Reply to
Jeff Liebermann

That worked.

yes ^M | netcat 217.120.43.67 8073

worked for a while, then slowed down, then stopped. Then plain old netcat wouldn't let me back in for several seconds... but now it works again. Tried yes | netcat again and same pattern. So your GPS data server *and* your traffic shaping works. :)

In case you're looking at the logs, I'm the guy from 69.247.x.x .

Matt Roberds

Reply to
mroberds

I was so the nerd's nerd that I was called "the professor" ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142     Skype: skypeanalog  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

If I was a betting man, I would put money on none of us on this newsgroup having been a cool kid in junior high.

Reply to
Ralph Barone

On a sunny day (Wed, 6 May 2015 20:01:02 +0000 (UTC)) it happened snipped-for-privacy@att.net wrote in :

Wed, 06 May 2015 19:57:04 GMT connect from host 69.247.192.7 port 33168 Wed, 06 May 2015 19:58:29 GMT connect from host 69.247.192.7 port 33196 Wed, 06 May 2015 19:59:34 GMT connect from host 69.247.192.7 port 33212 Wed, 06 May 2015 20:00:00 GMT connect from host 69.247.192.7 port 33208 Wed, 06 May 2015 20:01:43 GMT connect from host 69.247.192.7 port 33240 Wed, 06 May 2015 20:01:52 GMT connect from host 69.247.192.7 port 33236

What happens is that if you use netcat like that, then it does not set the 'keepalive' option on the socket. That means the automatic firewall of most ISPs will disconnect the link after some time, unless you keep sending continuously. That firewall will silently drop the packet, so the sever has no way of knowing the link is down. If you then come back that causes chaos, and the sever will exit (I just added an exit() for that case in the code).

I expected that to happen, so I run it like this: root@raspberrypi:~/compile/pantel/rgpspc# while [ 1 ] ; do ./rgpspc -2 -x 1>/dev/zero 2>/dev/zero ; echo retry ; sleep 10; done retry retry retry retry retry

I should add echo retry; date; to find out when and then from the log who did-dit.

There is also the 'Addres already in use' error if you restart the server too fast. Linus takes a minute or so to release a dead socket for reuse, unless you specify otherwise.

root@raspberrypi:~/compile/pantel/rgpspc# ./rgpspc -x rgpspc: bind() failed because: Address already in use aborting.

This issue is important, in my client-server application I have the client set the socket keepalive option, and instruct the Raspberry to use short timeouts. ISPs are aggressive with that, here it times out in a minute or so.

Normally I think web browsers will use the keepalive TCP handshake, and, for if you write code, more info here:

formatting link

In C: int set_socket_keep_alive(int socket) { int a; int optval; socklen_t so; socklen_t optlen = sizeof(optval);

if(verbose) { fprintf(stderr, "set_socket_keep_alive(): arg socket=%d\n", socket); }

so = sizeof(int); //int getsockopt (int SOCKET, int LEVEL, int OPTNAME, void *OPTVAL, socklen_t *OPTLEN-PTR) a = getsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &optval, &so); if(a < 0) { perror("getsockopt()");

return 0; }

if(verbose) { fprintf(stderr, "set_socket_keep_alive(): SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); }

/* Set the option active */ optval = 1; optlen = sizeof(optval); // int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) a = setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen); if(a < 0) { perror("setsockopt()"); close(socket);

return 0; }

//fprintf(stderr, "SO_KEEPALIVE set on socket\n"); /* Check the status again */ //int getsockopt (int SOCKET, int LEVEL, int OPTNAME, void *OPTVAL, socklen_t *OPTLEN-PTR) a = getsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen); if(a < 0) { perror("getsockopt()"); close(socket);

return 0; } if(verbose) { fprintf(stderr, "set_socket_keep_alive(): SO_KEEPALIVE is %s\n", (optval ? "ON" : "OFF")); }

return 1; } /* end function set_socket_keep_alive */

And then also set the Linux timeouts: system("echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time"); system("echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl"); //system("echo 10 > /proc/sys/net/ipv4/tcp_keepalive_probes");

You could also set the keepalive flag in netcat I think: This is the raspberry netcat: -k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option.

-l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored.

My Slackware netcat does not have this option... -k

As to that subject, in the very old version of netcat (nc) for early days (< year 2000) there were less options and it was more powerful. many of my script broke in teh new versions.

I do suspect Big B[r]other having a hand in f*cking up netcat as it was too easy for a kid to write a denial of service attack in one line bash... Well I won't write it here, obviously that would get me a free ride to Quantanamo, especially now trips to Cuba are allowed it would.. well we need some poly-ticks to stay on topic I guess. I have seen options added to netcat like tunneling and what not to maybe camouflage the evil work done. They seem to think that hose who can write C do not do bad things. I tell you man, with the old netcat and a PC you can^H^H^H could take down the internet world wide for days.

There is more, I only culd remember how I fixed that socket in use...

Reply to
Jan Panteltje

Yes I see. I have never used it to hack up a "server", just for backups and file transfers sometimes (I use rsync for everything now).

I really need to start playing with this stuff. It's the current Big Thing you know.

On the shelf next to me I am accumulating little 3$ ebay spi modules. Wifi, bluetooth, gprs, ethernet - but no time to do anything with them.

--

John Devereux
Reply to
John Devereux

Don't do that! Now I have to burn down my house and get a new tinfoil hat! :)

I'm trying yes | netcat again just now and it seems to be going at high speed without slowing down.

echo retry; date; tail -3 /var/log/rgpspc.log

Yeah, I've seen that in netstat output before.

I have Debian. It has a few different packages: netcat-traditional (the

*Hobbit* version, which doesn't have -k), netcat-openbsd (the "new" version, has -k) and netcat6 (with IPv6 support, which seems to have been derived from the *Hobbit* version).

I dunno... sometimes distros can f*ck up on their own. I am currently figuring out how to not upgrade to Jessie, so as to avoid L-nn-rtware.

# ping -f 1.2.3.4

Matt Roberds

Reply to
mroberds

On a sunny day (Thu, 7 May 2015 21:10:35 +0000 (UTC)) it happened snipped-for-privacy@att.net wrote in :

Yes my sincere appologies Your headers do not include 'Posting host 69.247.XXXXXXXXXX some do, that is how I can cross correlate sometimes.

But I hope you are aware that there are only 65536 possibilities, so, written in Rattler: for i 0 to 55 for j = 0 to 255 host 69.247.i.j if(matches your headers / IP/ found you

can be executed by anyone?

I have modified some code, In fact it is now running on port 8080 with Apache and PHP, and on 8083 without.

I was trying so sent pure html, but really no 2 browsers interpret things the same way (tried 5). So that needs some work. Maybe in the weekend.

Raspberry Linux is Debian basically. Thats is a decent netcat, you can for example do: while [ 1 ] ; do clear; echo "" | netcat 217.120.43.67 8073 ; sleep 1 ; done

Plz do not leave out the 'sleep 1' for net congestion...

Yes did not the saying go: 'Do not blame on malice what can be explained by incompetence...'

What is Jessie / Not Loch Ness monster Nessi?

I just did read a high court in the US decided that NSA's storage of data is illegal. No reply from NSA yet.

Reply to
Jan Panteltje

That is a feature. :) The server I use even advertises it:

"Our server does not publish any personal information about the user in posting headers that the user does not publish himself. In particular, the user's IP address is not visible to third parties."

I know. A little quality time spent with nslookup/dig and Google might narrow the range even further. I'm just not going to make it *easy* for people.

That's OK, though! The people who originally moved to Web design from print layout have never been OK with the idea of different browsers working differently, which is part of the reason why HTML and web design are all screwed up now.

Worgs grate!

I think this particular thing is a combination of both. Basically, somebody decided that Linux should be more like Windows, and run 37 things that used to be independent daemons in one huge monolithic svchost.dll.

Next version of Debian. Right now I run Wheezy (version 7). Jessie is version 8; it just came out a week or two ago.

It was the United States Court of Appeals for the Second Circuit, which is good, but it isn't that high. I wouldn't expect NSA to say anything one way or the other unless it gets to the Supreme Court.

Matt Roberds

Reply to
mroberds

That's not such a bad idea and nothing very new. It's part of the natural evolution of computing. When something is working and 98% done, someone always has a better idea that puts things back to mostly non-working and about 75% done[1]. I think the logic is that it's rather tedious to fix something that's broken, but far more fun and easier "fixing" something that's done and working.

Incidentally, Busybox uses a similar idea and has been around for about 20 years: I'm not going to count how many programs have been squeezed into a 90 KByte binary but I'll guess about 200.

Also, to find what's currently running under SVCHOST.EXE under Windoze is currently doing behind your back: tasklist /svc /fi "imagename eq svchost.exe"

[1] The learning curve is always uphill.
--
Jeff Liebermann     jeffl@cruzio.com 
150 Felker St #D    http://www.LearnByDestroying.com 
Santa Cruz CA 95060 http://802.11junk.com 
Skype: JeffLiebermann     AE6KS    831-336-2558
Reply to
Jeff Liebermann

On a sunny day (Fri, 8 May 2015 18:35:59 +0000 (UTC)) it happened snipped-for-privacy@att.net wrote in :

OK, I did the html thing.

It now detects if you are using a web browser or netcat by looking for the GET index.html

That means you can get the pure html too with netcat by typing: echo "GET /index.html" | netcat 217.120.43.67 8073

In case of netcat no welcome messages, but just hit ENTER key,

It works with auto-refresh tested in: firefox seamonkey (named = 'iceape' in Debian on Raspi) midori (Raspberry)

http://217.120.43.67:8073/index.html

From the same server as text, type ENTER for new data: netcat 217.120.43.67 8073

From the same server with auto update only with Debian netcat: while [ 1 ] ; do clear; echo "" | netcat 217.120.43.67 8073 ; sleep 1 ; done

Same some other netcat (nc): while [ 1 ] ; do clear; echo "" | nc -q 1 217.120.43.67 8073 ; sleep 1 ; done

I used tables in html to align some data. Fontsize is set on the command line, default 12 pixels should work on most browsers.

If anybody wants this C soure (GPL) let me knwo here, it is quite a bit of code. this is SPC01 magnetic compass, air pressure, and temperature on i2c via Raspberry GPIO MPU6050 6 axis accelerometer plus temperature on i2c via Raspberry GPIO EM-411 GPS module on USB with an ebay RS232 to USB to adaptor. I am sure you can do that directly on the GPIO too, but the GPS module will not fit in the Raspi box.

The GPIO connections are shown at the top of the C code.

Does not work in: lynx dillo (Raspberry) probably not in MS exploder either.

Reply to
Jan Panteltje

On a sunny day (Sat, 09 May 2015 14:13:05 GMT) it happened Jan Panteltje wrote in :

PS filesize:

-rwxr-xr-x 1 root root 55356 May 9 20:39 rgpspc

55 kB (kilo byte)

Libraries used. only the basics: root@raspberrypi:~/compile/pantel/rgpspc# ldd rgpspc /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0xb6f92000) libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6f10000) libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6ef1000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6dc2000) /lib/ld-linux-armhf.so.3 (0xb6f9f000)

That is quite a bit different from Apache and php5 together plus the half a hundred libs loaded by Apache: -rwxr-xr-x 1 root root 368584 Jan 10 17:01 ../lib/apache2/mpm-prefork/apache2 -rwxr-xr-x 1 root root 7568252 Mar 29 18:26 /usr/bin/php5

root@raspberrypi:/usr/sbin# ldd apache2 /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0xb6eb3000) libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0xb6e61000) libaprutil-1.so.0 => /usr/lib/libaprutil-1.so.0 (0xb6e3c000) libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0xb6e0f000) libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6de7000) libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6dc8000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c99000) /lib/ld-linux-armhf.so.3 (0xb6f25000) libuuid.so.1 => /lib/arm-linux-gnueabihf/libuuid.so.1 (0xb6c8c000) librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6c7d000) libcrypt.so.1 => /lib/arm-linux-gnueabihf/libcrypt.so.1 (0xb6c46000) libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6c3a000) libexpat.so.1 => /lib/arm-linux-gnueabihf/libexpat.so.1 (0xb6c10000)

root@raspberrypi:/usr/sbin# ldd /usr/bin/php5 /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0xb6fc4000) libcrypt.so.1 => /lib/arm-linux-gnueabihf/libcrypt.so.1 (0xb6f7c000) libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6f5e000) libonig.so.2 => /usr/lib/libonig.so.2 (0xb6f13000) libcrypto.so.1.0.0 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0 (0xb6db0000) libssl.so.1.0.0 => /usr/lib/arm-linux-gnueabihf/libssl.so.1.0.0 (0xb6d60000) libdb-5.1.so => /usr/lib/arm-linux-gnueabihf/libdb-5.1.so (0xb6c19000) libqdbm.so.14 => /usr/lib/libqdbm.so.14 (0xb6bdc000) libbz2.so.1.0 => /lib/arm-linux-gnueabihf/libbz2.so.1.0 (0xb6bc3000) libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0xb6b82000) librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0xb6b72000) libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6b01000) libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6af6000) libnsl.so.1 => /lib/arm-linux-gnueabihf/libnsl.so.1 (0xb6ada000) libxml2.so.2 => /usr/lib/arm-linux-gnueabihf/libxml2.so.2 (0xb69ad000) libgssapi_krb5.so.2 => /usr/lib/arm-linux-gnueabihf/libgssapi_krb5.so.2 (0xb6974000) libkrb5.so.3 => /usr/lib/arm-linux-gnueabihf/libkrb5.so.3 (0xb68c6000) libk5crypto.so.3 => /usr/lib/arm-linux-gnueabihf/libk5crypto.so.3 (0xb6896000) libcom_err.so.2 => /lib/arm-linux-gnueabihf/libcom_err.so.2 (0xb688b000) libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6863000) libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6733000) /lib/ld-linux-armhf.so.3 (0xb6fd1000) libresolv.so.2 => /lib/arm-linux-gnueabihf/libresolv.so.2 (0xb671f000) libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6700000) liblzma.so.5 => /lib/arm-linux-gnueabihf/liblzma.so.5 (0xb66d9000) libkrb5support.so.0 => /usr/lib/arm-linux-gnueabihf/libkrb5support.so.0 (0xb66ca000) libkeyutils.so.1 => /lib/arm-linux-gnueabihf/libkeyutils.so.1 (0xb66be000)

I will now remove the support in rgpspc for Apache + php.

Reply to
Jan Panteltje

Works for me with Iceweasel 31.6.0. Also works with w3m version

0.5.3+cvs-1.1055.

On x86_64 Debian Wheezy:

Works with netcat.openbsd, doesn't work with netcat.traditional

Works with both netcat.openbsd and netcat.traditional

It doesn't work for me if I do

$ lynx 217.120.43.67:8073

I suspect Lynx is saying "GET /", which your code doesn't look for. But if I do

$ lynx http://217.120.43.67:8073/index.html

then it works and I get the first screen. Lynx isn't following the refresh by default, but it does give you a link at the top of the screen and puts the cursor on it, so if you hit Enter, it reloads.

*launches W2K under qemu* *waits*

Works for me in IE IE 6.0.2800.1106. With auto refresh! :)

formatting link

Matt Roberds

Reply to
mroberds

Oh, and your logs are all binary now, and you have to use a viewer program to see them. The binary format won't change too much. Maybe.

Oh, and the developers decided that any instance of the word "debug" anywhere on the kernel command line was the clue for their overgrown init system to issue enough debug messages to fill up the kernel buffer and make the system unbootable.

Oh, and one of the developers pissed off Torvalds enough that he quit (or threatened to quit) accepting their code into the kernel. (Linus has been accepting patches from thousands of people since the early

1990s, so I suspect he has grown rather thick skin over that time.)

Oh, and distributions are starting to depend on it, to the exclusion of previous init / cron / syslog systems. (Debian just fell; Gentoo is the last sane major distribution.)

I dunno. MS-DOS seems pretty stable these days.

I've used Busybox before, on shipping commercial systems, and it works fine on resource-constrained embedded systems. Its tools can't do everything the "full" tools do, but sometimes just having something grep-like (or awk, or whatever) is all you need.

I'm not sure whether to be amazed or concerned that for one system I worked on, there are a few hundred, maybe a thousand, instances of Busybox vi deployed around the US.

Good to know, thanks! When I have had the ability to install software, I have used Process Explorer to do a similar thing.

Matt Roberds

Reply to
mroberds

On a sunny day (Sun, 10 May 2015 05:39:55 +0000 (UTC)) it happened snipped-for-privacy@att.net wrote in :

Cool.

Yes, that is sort of the problem with other browsers, they try to protect you from going to unknown possibly bad sites.

Bit like a car that pops up a menu: 'Are you sure you want to break (Y/n)?'

That is nice, a plus for MS.

I will clean up the code, run some more tests, and probably release a tgz package later. It is a lot of files.

Reply to
Jan Panteltje

So here it is, source release:

formatting link

Reply to
Jan Panteltje

So, for the US I can download all vector charts from the waterways for free from NOA, after > 24 hours crunching on a Raspi 16 GB SDcard, that disk was full, but I had most US waterways with depth info in opencpn running. Now you would think that the Netherlands with a rule the waves heritage, and water everywhere, would also have similar ENC charts with water depth for free. Wrong. Only of a small part of the country. I bough the official paper charts. Then that idea.. Taped the maps to the wall, camera, largest resolution, click click. The soft was just a few hours to think of a protocol and way to recognize location and scale. Then added it to rgpspc and has it plot the boat or whatever in the chart:

formatting link

Just for fun :-) Garmin my foot.

So, this is developed on the PC, so have to port it to Raspi. Resolution could be better, but I pictured all the detailed cards too, so there the resolution is more than enough.

Now can I serve that to a webpage? It is just a background image ,and then data on top. :-)

Reply to
Jan Panteltje

Here are some tricks I used: First on the official charts the longitude and latitude is marked. So took pictures of the charts, processed the images and cut the edges at exactly the data area, so where the chart lon and lat begins.

Then named the charts like this (example): ijselmeer,3187.6,300.0,3150.0,344.2,.ppm

where chart_name, latitude top left, longitude top left, latitude bottom right, longitude bottom right (all in minutes of arc and basically in CSV format) and ppm picture format because I already wrote all the routines that format, and it is lossless.

Display chart as image.

Check is made if object (boat, train, whatever) is in the chart area.

if it is not look for a matching chart file (to be done).

Then it is simple math: subtract position from start chart, get width chart in minutes of arc get height chart in minutes of arc divide position by that. that to get a percentage. Multiply width in pixels by h percentage to get h pixel at location multiply height in pixels by v percentage to get v pixel at location Draw something there.

Refresh display once per second (with new GPS data).

There are lot of fancy things you can think of, such as viewport small display moving with object. Automatically switching to highest resolution chart available. Add AIS info (I have that working with rtl_sdr in opencpn). Add AIS alarms. I now have trace working, it shows a line where you moved.

Some more sensors just came in.. (test project). That small monitor has also arrived and works great...

Reply to
Jan Panteltje

I wrote: al lot

Transparent text why does this monitor make it green? It is OK on a normal monitor. Ok will have to try PAL, not NTSC.

formatting link
The boat is the little green dot. Note the scale, 500 meters, clear within view.

Auto map selection for the best map works. GPS is not any better, the green dot moves around.. 10 meters I think.

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.