Displaying GPS Data ?

Hello Group;

I have a webpage server running on a BBB. This page currently serves (streams) video from my robot.

I would like to also display the Lat/Long from the onboard GPS.

I have CGPS installed and working. It writes text to the console.

What I would like to know is how to send this text to a text box or whatever on the web page.

I’m thinking node.js + java script?

Thanks;

Bill

“All that is necessary for the triumph of evil is that good men do nothing” Edmond Burke (1729 - 1797)

http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book

http://ca.linkedin.com/pub/bill-pretty/2b/b07/602

Nodejs + child_process.exec to run the GPS executable, and then in a callback parse the output. Then do with it as you wish. Something like this:

http://www.dzone.com/snippets/execute-unix-command-nodejs

In that example though the person is just printing the output of pwd to stdout, etc. But the concept is the same-ish.

I did the same thing with a TEMPer v1.4 USB thermometer dongle. Running the application through Nodejs, and then parsing the output in a callback. Let me see if I can find my code, or notes.

My code is rather overly complicated for the sake of explanation . . . but here goes.

In my snippet below I’m using socket.io, which for this explanation is not really important. Except since I’m using socket.io.emit(), basically sending the value of stdout to the client, and dealing with the “data” on the client side(browser) by using client side javascript. You could very easily deal with the data on the server backend. Such as the commented out line console.log(stdout); , but for a webserver type application console.log() is not very useful for other than testing output.

Anyway, the executable of course is “temperv14” with a cmd line switch of “-F” which instructs the command to only output a float / double value representing the temperature in Fahrenheit. Nothing else. Which made dealing with the data on the client side trivial.

io.on(‘connection’, function(socket){
var exec = require(‘child_process’).exec;
var child = exec(‘temperv14 -f’, function(err, stdout, stderr) {
if (err) {
console.log(err);
} else {
//console.log(stdout);
io.emit(‘temperature’, stdout + ‘F’);
}
});
});

Thanks. That would be GREAT !!

complete code for the Nodejs app

index.js
http://pastebin.com/w4PiZ23t

index.html
http://pastebin.com/vbDx1KG0

package.json:
http://pastebin.com/u4vc0w8x

It’s a rather simple app, but it could be as complicated as one would like. I pastebin’d package.json so you would know which versions of express, and socket.io I used. Which can be pretty important if you’re new to nodejs like I was when I first wrote this app . . . I also have noted somewhere but I’ll have to dig for them, it’s been several months since I learned / wrote this, and javascript / nodejs is not really one of my strong points . . .

William,

Sorry, the only notes I could find are rather incomplete, and I could not find the puTTY log sessions I used to have on my old laptop. I could piece together a couple of txt note files I kept that are sort of exact steps I used to create the whole setup. More or less.

Something to consider though. I do not use the any of the “official” images for my own “production” images. I have kind of a what some may consider a “convoluted” setup. I use two images, both of which are NFS rootfs;s. One for development, and one for “production”. The development image I use to install all necessary development tools such as gcc, build-esential, checkinstall, etc. On which I built my own version of nodejs( 0.10.29 if memory serves ). When then I created a Nodejs *deb package to install on the “production” image.

My production image is pretty much just RCN’s bare-fs rootfs, with a minimal set of what I consider necessary tools installed. openssh-server, psutils, ntpdate, etc. The whole thing including Nodejs sits( again, if memory serves ) at around 95M total size in flash though . . . which is why my setup is so convoluted . . .

Anyway, if you’re interested, let me know, and I will try to get you something as complete / accurate as possible.

Not to worry.

I do have one question though.

My actual image size is usually about 3GB, however I can only find 8GB uSD cards.

I tried just formatting half of the card (4GB) but I still get an 8GB image, using the ‘standard’ imaging tools.

Is there some way I can Image just the boot partition and the roofs?

Thanks;

Bill

Yes. By using tar, and the “imaged” partition(s) would have to be “offline”.

Meaning you would have to put the sdcard into a system that was already running Linux. Here is the gist of things: http://www.aboutdebian.com/tar-backup.htm

So anyway, once you have a rootfs backup, you’d have to use fdisk, or sfdisk to create a new partition(s), then makefs to create the file system(s) type that you wanted. Finally, tar the image onto the new filesystem.

errr, ooops, you must make sure the boot partition is marked as active boot with fdisk.

OK, a few caveats I noticed about that article.

First, you’d be mounting the sdcard on a mount point created by yourself. such as:

sudo mkdir /media/rootfs/

sudo mount /pathto/sdcard /media/rootfs

Second, once the sdcard is mounted, you will have to cd into the topmost directory such as:

cd /media/rootfs

Once here, if you run ls you should see your basc rootfs directory structure. Once that is confirmed . . .

makedir ~/backup
sudo tar -zcvf ~/backup/rootfs.tar.gz .

NOTE: the dot after the full tar command. It is necessary to tell tar what to do, and in this case, tar the entire current directory structure.

Anyway, you can probably figure out how to use fdisk / sfdisk to create a partition the size you want. As well as using makefs.ext4 or whichever filesystem type you want on that partition. But make sure while in fdisk you mark the boot partition as boot

Once all that is done . . .

sudo mount /pathto/sdcard /media/rootfs
sudo tar xzvf ~/backup/rootfs.tar.gz -C ~/media/rootfs

And that should be it. If for some reason it does not boot, put the sdcard back into your running Linux machine, run fdisk on it, and double check to make sure the boot partition is maked as active boot. This has tripped me up a few times myself, often enough to where I usually double check with fdisk before I take it out of the working Linux system I’m using to begin with.

Darn it, I forgot the most important thing, and I have no way to test this to make sure it is 100% accurate - right now.

You need to backup the MBR in the case of a single partition setup. something like this:

http://www.cyberciti.biz/faq/howto-copy-mbr/

However, I’m not 100% sure how large the MBR is or how to check. I’m mostly sure Robert has this set to 1M but am not 100% positive. But if it is . . .

dd if=/pathto/sdcard of=/some/path/mbr.bak bs=1024 count=1

This would be done sometime prior to using fdisk / sfdisk to create a new partiton setup on the sdcard.

Then once you have created a new partition with fdisk / sfdisk you would . . .

dd if=/some/path/mbr.bak of=/pathto/sdcard bs=446 count=1

Crap I hope you haven’t started on this yet. Tell you what give me a few hours, and I can test this all myself and have exact steps when done.

Yeap, 1MB hole to make most things happy..

Regards,

OK cool. Not as bad as I was initially thinking it could be either. Just a PitA making sure he would have a usable uboot / MLO, in the case of single partition setup. If dual partition setup, my worries were for nothing.

Hi Guys;

Thanks for the on-going help J

After reading the posts I realized that I should have told you what image I was using.

My bad.

root@beaglebone:~# uname -a

Linux beaglebone 3.8.13-bone70 #1 SMP Fri Jan 23 02:15:42 UTC 2015 armv7l GNU/Linux

bone-debian-7.8-console-armhf-2015-03-01-2gb.img

BeagleBoard.org Debian Image 2015-03-01

Bill

I think thats the same exact image I’m working with right now william. Just now to the part where I’m logging how to do this. and . . . it’ll be a lot of text because I want you, and everyone to see the whole workflow, but hopefully you’ll be able to find the stuff thats relevant to you fairly easily. May take about another ~30 minutes or so. Reading / writting flash media is SLOOOOOW going heh.

Going to be a while longer, I messed up. Was copying bytes from the MBR instead of kilobytes . . . So, I pretty much have to start over from scratch. All good though I need notes on how this is done for myself too. Maybe I’ll write a book someday ? hah !

Starting from a blank sdcard.

william@eee-pc:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 9.3G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 137.8G 0 part /home
sdb 8:16 1 14.7G 0 disk

william@eee-pc:~$ ls downloads/linux-images/
bone-debian-7.7-console-armhf-2014-11-19-2gb.img
bone-debian-7.8-console-armhf-2015-03-01-2gb.img
bone-debian-8.0-console-armhf-2015-05-04-2gb.img

william@eee-pc:~$ sudo dd if=/home/william/downloads/linux-images/bone-debian-7.8-console-armhf-2015-03-01-2gb.img of=/dev/sdb
3481600+0 records in
3481600+0 records out
1782579200 bytes (1.8 GB) copied, 615.607 s, 2.9 MB/s

Eject sdcard
william@eee-pc:~$ sync

re-insert sdcard
william@eee-pc:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 9.3G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 137.8G 0 part /home
sdb 8:16 1 14.7G 0 disk
└─sdb1 8:17 1 1.7G 0 part

william@eee-pc:~$ sudo mount /dev/sdb1 /media/rootfs/
[sudo] password for william:

william@eee-pc:~$ df -h /media/rootfs/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 1.7G 214M 1.4G 14% /media/rootfs

Eject card
william@eee-pc:~$ sync

Attempt to boot beaglebone from card. As I just happen to know which IP the beaglebone will take from DNS on a fresh install . . .

william@eee-pc:~$ ssh debian@192.168.254.36
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is

Please contact your system administrator.
Add correct host key in /home/william/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/william/.ssh/known_hosts:1
ECDSA host key for 192.168.254.36 has changed and you have requested strict checking.
Host key verification failed.

So, wrong ECDSA key, but it’s there, and happily blinking away. Correct way to deal with the problem ? Most definately not, but I do not care . . .

william@eee-pc:~$ rm ~/.ssh/known_hosts
william@eee-pc:~$ ssh debian@192.168.254.36
The authenticity of host ‘192.168.254.36 (192.168.254.36)’ can’t be established.
ECDSA key fingerprint is .
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.254.36’ (ECDSA) to the list of known hosts.
Debian GNU/Linux 7

BeagleBoard.org Debian Image 2015-03-01

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

debian@192.168.254.36’s password:
debian@beaglebone:~$

Ok all good, but while I’m here going to take care of g_ether.[EDIT] But not very well as you can see I forgot to edit /etc/network/interfaces as well, and did not edit uEnv.txt to get rid of systemd as I usually do . . .

debian@beaglebone:~$ sudo nano /etc/modules
—>g_ether
debian@beaglebone:~$ sudo shutdown now -h

Broadcast message from root@beaglebone (pts/0) (Sun Mar 1 21:36:59 2015):
The system is going down for system halt NOW!

Eject sdcard from the beaglebone, and put back into Linux workstation.

william@eee-pc:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 9.3G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
└─sda6 8:6 0 137.8G 0 part /home
sdb 8:16 1 14.7G 0 disk
└─sdb1 8:17 1 1.7G 0 part

Backup MBR

william@eee-pc:~$ sudo dd if=/dev/sdb of=/home/william/mbr-sdb.bak bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0680266 s, 15.4 MB/s

Backup rootfs
william@eee-pc:~$ sudo mount /dev/sdb1 /media/rootfs/
william@eee-pc:~$ cd /media/rootfs/
william@eee-pc:/media/rootfs$ sudo tar -zcvf ~/backup/rootfs.tar.gz .
william@eee-pc:/media/rootfs$ cd ~
william@eee-pc:~$ sudo umount /media/rootfs/

Wipe out the MBR, and partition table RCN style

william@eee-pc:~$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB) copied, 0.737684 s, 14.2 MB/s

Copy MBR ( MLO / uboot.img ) to disk.

william@eee-pc:~$ sudo dd if=/home/william/mbr-sdb.bak of=/dev/sdb bs=512k count=1
1+0 records in
1+0 records out
524288 bytes (524 kB) copied, 0.0429171 s, 12.2 MB/s

Check sfdisk version.

william@eee-pc:/media/rootfs$ sudo sfdisk --version
sfdisk from util-linux 2.20.1

Create new partition with sfdisk

william@eee-pc:~$ sudo sfdisk --in-order --Linux --unit M /dev/sdb <<-EOF
> 1,1000,0x83,*
> EOF

Checking that no-one is using this disk right now …
OK

Disk /dev/sdb: 14991 cylinders, 64 heads, 32 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End MiB #blocks Id System
/dev/sdb1 * 1 1000 1000 1024000 83 Linux
/dev/sdb2 0 - 0 0 0 Empty
/dev/sdb3 0 - 0 0 0 Empty
/dev/sdb4 0 - 0 0 0 Empty
Successfully wrote the new partition table

Re-reading the partition table …

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

Create file system ( format ) the new partition.

william@eee-pc:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
64000 inodes, 256000 blocks
12800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=264241152
8 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

Copy over rootfs

william@eee-pc:~$ sudo mount /dev/sdb1 /media/rootfs/
william@eee-pc:~$ sudo tar xzvf ~/backup/rootfs.tar.gz -C /media/rootfs

Eject sdcard
william@eee-pc:~$ sync

Place sdcard into beaglebone, and attempt to boot. Then pray to the UNIX gods you did not do something silly like me . . . Like trying to substitute Kilobytes with Bytes in dd . . .

william@eee-pc:~$ ssh debian@192.168.254.36
Debian GNU/Linux 7

BeagleBoard.org Debian Image 2015-03-01

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]
debian@192.168.254.36’s password:
Last login: Sun Mar 1 21:34:48 2015 from 192.168.254.162
debian@beaglebone:~$ uname -r
3.8.13-bone70

debian@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Image 2015-03-01

debian@beaglebone:~$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p1 969M 181M 738M 20% /

whew

A note for you william.

sudo sfdisk --in-order --Linux --unit M /dev/sdb <<-EOF

1,1000,0x83,*
EOF

The value in bold “1000” you’re probably going to want as:

sudo sfdisk --in-order --Linux --unit M /dev/sdb <<-EOF

1,4000,0x83,*
EOF

To create a ~4G parttion.