My project remote monitoring pc audio and alarm

Puppy related raves and general interest that doesn't fit anywhere else
Message
Author
AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

My project remote monitoring pc audio and alarm

#1 Post by AdrianH »

This project is keeping my mind active, teaching me a few things on computing and Linux so not all bad.

The idea is to have a computer, small and low powered at one location, that is capable of streaming audio to a computer at another, to act as a sort of monitoring or intercom system if needed between my home and another.

There are plans to add a small radio receiver device as used on car alarms or similar and a key fob so when pressed the computer can undertake a string of tasks.

When I got the idea, I picked up a couple of 2003/4 old HP T5700 thin clients for less then the cost of the Raspberry Pi's. They were an ideal candidate for small Linux distro's and I tried several before sticking with puppy.

The units have decent sound cards built in to them giving a watt or so of audio and having a mic boost function to lift the mic gain by 20 dB.

I did struggle with the various flavours of Puppy though until I came across one that SSH server would work. Being an old device I tried wary, then precise and now just tried slacko.

The 5.6 slacko has allowed me to install SSH-srv, and for it to work as is, when enabled, I could not get any other versions to do this.

I have installed icecast, darkice and rsound, enabled SSH and stopped other services such as logging, cups and freq scaling and also stopped it going into X, so it basically now sits here for testing with just a network, power and microphone connection.

The icecast/dark ice streams at 4Kib/s when on, so is not bandwidth heavy, and depending on the audio player I use can get latency less then a second over my internal network.

I also plan to use a package called rsound (rsd & rsdplay) to send return audio when needed, this is heavier on bandwidth at around 15 Kib/s but is quite quick.

The pc draws 12 watts power when running and the processor is running around 7 to 9% usage with SSH/darkice/icecast running, so has plenty of spare, peak load is around 16 watts which is comparable to my old desktop on standby!

I still have plenty to learn to complete. I need to run a script for icecast, darkice and rsound to start up automatically at boot up and shut-down cleanly on power off.

From the remote SSH terminal up to now I have just been using:
# icecast -c /etc/icecast.xml &
# darkice -c /etc/darkice./cfg &
# rsd &

The & running them as daemons, then using top to determine the process numbers to kill them later.

Then it will be on to the radio key fob part, to have the pc detect a button press and then do a string of functions and repeat until action is taken, be it send emails, notify a remote pc or something.

I am open to ideas, someone may know of programs I could use for this, or better ways of going about the project, I am all ears, or eyes in this case.

Cheers

Adrian

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#2 Post by AdrianH »

I have a script added to rc.local that now runs up the audio packages icecast darkice and rsound, thanks to help from mikeb in the forum help section.

Now to think on what is needed to page me if help is needed, thinking of trying to find a sms gateway, or similar to phones.

Adrian

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#3 Post by 01micko »

Hmmm.. maybe install mailx (formerly nail), and just try to push a message to yourphNumber@yourprovider.com (YMMV).

Failed here but it can take a few hours. Probably not what your after. Unfortunately most gateways require captchas >> requires GUI >> requires a pebkac :(

On the bright side, since symbian most phones/providers support email, which should be instant, just configure a prominent notification tone on the phone.

Interesting project, glad slacko could be of some use.
Puppy Linux Blog - contact me for access

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#4 Post by Flash »

Just curious, have you tried to get this thing to boot without a keyboard or display attached to it?

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#5 Post by mikeb »

Shutdown cleanly...hmmm

busybox poweroff works but not exactly clean unless everything runs in ram.
The more normal route has a problem over ssh because of things like the network closing in mid script and no user interaction.... lack of real init and shutdown -h now basically....with slax its no probem. I have tried ways but as ssh is in a sub shell you cannot truly get at init.

Other thoughts...have you played with remote X over ssh?
bit more sophisticated...me had visions of using a vid cam program or even skype that way.

Esd can be used to send sound over ssh though think its incomplete in puppy....perhaps a method to be avoided but thought I'd throw it in there.
all sounds fun
mike

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#6 Post by AdrianH »

Just lost a reply, thought I sent it, never mind sure it will turn up!

01miicko

I have searched for sms gateways here in the UK and think for the cost of a few UKP for a hundred of so texts I will pay the price, a few of them have a developers contact so I plan to send an email or two to describe what I am trying to do and see if they have a console command I could use. It will take me a while, spending most of my weekends and evenings playing at this.

Flash

yes I have the unit sat here powered up without keyboard, mouse or screen connected, access via remote shell.

In the bios I can set three levels of halt on errors, settings are:
all errors
no errors
all, but keyboard

presently set as all but keyboard.


mikeb

Hi mike thanks for your help. when I mentioned shutdown cleanly, I was assuming that just rewbooting the pc may cause an issue and as I am backgrounding icecast, darkice and rsd assumed I needed to kill them before shutdown or reboot.

I have previously always used top to determine the process numbers and then used kill to stop each one.

It appears that just powering off or rebooting causes no problems or non to date that I can see. I am concerned about file space as the Thin client runs from 256K flash and 512 K ram.

Adrian

p.s.

In case anyone is wondering , this project is for use within my own family, even though there is a fixed land line, a mobile with a panic button (normally to be found in a handbag somewhere in the house) this is to try and give me a bit more peace of mind.

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#7 Post by AdrianH »

Just an update.

Down to much and I mean much assistance from the forum members, things are progressing.

From the computer I can send perl scripts to the sms gateway and they go through and out to the mobile within seconds, say 6 to 10 seconds so that is working OK.

I can stream audio from the computer and with another bit of software talk back to it, although not to sure about getting it to run on other platforms such as windows etc.

Had a Chinese IP trying to hack through SSH so now have blocked over 130 thousand Ip address from that continent.

I have proved by going to another location that I can access via ssh and things tend to work as expected.

What I can not crack is how to write my own scripts to read the parallel port and then have decision loops to act as the main monitoring part.

At this stage I can not even figure out how to get the number value returned from pin0x379 to be accepted within a Bash script. My books and most of the net seems to show examples of data entry as strings.

But still, I hope to get there.

By the way in case anyone is interested I think of this as more of an embedded project small scale and flash storage.

I picked up a couple of small cards from Ebay, these cards can accept SD memory cards and act like a 2.5 inch IDE drive, so just equipped a card with a 4 GB card and will install into a second thin client and see how it performs. I should be able to do a full puppy install on it.

Adrian

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#8 Post by Flash »

I hope you aren't getting that assistance via PM. That's not how the forum should be used. :)

Other people have had trouble booting without a display attached. Did you have to do anything to get it to work?

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#9 Post by AdrianH »

Flash wrote:I hope you aren't getting that assistance via PM. That's not how the forum should be used. :)

Other people have had trouble booting without a display attached. Did you have to do anything to get it to work?
No on both counts! All to be found in either the beginners or regulars section

mikeb and 01micko have been brilliant help.
I guess it is down to computers bios on the screens but, there is generally some way of switching off halt on errors tucked away within bios settings,

Adrian

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

Re: My project remote monitoring pc audio and alarm

#10 Post by mcewanw »

AdrianH wrote:
I am open to ideas, someone may know of programs I could use for this, or better ways of going about the project, I am all ears, or eyes in this case.
I also have a longtime interest in anything to do with remote pc monitoring (video or audio). Vovchik introduced me to a nice commandline email program, which you may find useful at some stage. Link to a version compiled by trapster here: http://www.murga-linux.com/puppy/viewto ... 068#730068

I have used this in the past to send motion video surveillance captures at regular intervals to my email account. I have been planning to use it to similarly send mp3 (or ogg) encoded audio, again triggered by some detected motion or audio detected event as part of a home security system.

Many years ago I have also used a pc parallel port to capture hdlc protocol packets with embedded tcp/ip over a satellite link - a simple protocol analyser (on an old 386 pc actually), but that was written in a mix of 80x86 assembler (for speedy capture) and C for processing and display and on msdos of all things (in around 1990...). I haven't investigated reading or writing to pc parallel port from Linux though (indeed pc parallel ports are becoming somewhat rare, which is a pity because they do provide a convenient and simple input/output interface for such projects as yours).

EDIT:

A quick google provided the following links re: parallel port and Linux:

http://www.tldp.org/HOWTO/IO-Port-Programming-6.html

http://yyao.ca/projects/ParallelPortLinux/

http://stackoverflow.com/questions/1785 ... t-in-linux

http://as6edriver.sourceforge.net/Paral ... ssing.html

http://maxy.homeip.net/old/parport/

http://www.bitwizard.nl/par/index.html
github mcewanw

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#11 Post by mikeb »

I hope you aren't getting that assistance via PM. That's not how the forum should be used. Smile
thats what I ended up doing for 2 years :D

Most port usage stuff is based around data transfer...simple on/off less commonly used but looks like some good links there. I was going to suggest a cheap SMBus card otherwise.

A different approach that occured to me... a usb numeric keypad only pad...if you know what I mean.....16 keys could be used as human interface or simply solder wires as keyboard switches and use the ps/2 card as a cheap interface..or cannabalise a junked full keyboard.

mike

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#12 Post by AdrianH »

I found a lot of the links when searching about linux and the parallel port, hence why I ended up with two executables parashell and pin.

Pin from command line gives the option to read each of the ports associated with the parallel connector such as data port status port command port etc.

An email back from the writer says it does work fine within a sh script?

Still trying that bit.

Adrian

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#13 Post by greengeek »

How many pins do you need to monitor on the parallel input? If you are only monitoring a single pin (eg monitoring a 'door open' switch or something) there is a way it can be done through usb by modifying a cheap usb keyboard. (SFR wrote some scripts for driving an entire PC via a single switch and I modded a usb keyboard for that purpose)

Or are you using more than one of the signals?

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#14 Post by AdrianH »

I am initially monitoring just one pin, but the hope is to monitor more. The status port has 5 pins and provides the output as a decimal number combining all 5.

My initial script from last night is:

Code: Select all

#!/bin/sh -x
# run try number 4
# This is a test script
# Pin resides in /bin
# Normal use is pin 0x379  where 0x379 is the status port in hex format
# Can not use port0x379 it has to have the space as the port number is a variable passed to pin
# result shpould be the response typically 120 decimal
# hope to use result as part of a if else and loop

status=0x379    # The number for the status port
smsdone=0       # To determine if sms message has been sent
debounce=0      # A Bit of software debounce

while : 
do
#       echo "infinite loops  hit CTRL+C to stop"

result=$(/bin/pin $status)      # The result of reading the status pins # Line 18
#echo $result

if test $result -gt 120 && test $debounce -eq 5 && test $smsdone -eq 0  # line 21
        then                    # To be at this point, the contacts have been closed for 500 mS 
#       echo "Yes"              # And the sms gateway has not been used
#       usleep 100000
#       echo $debounce
        /usr/etc/one            # The computer emits a sequence of 'beep' musical sounds
        /usr/etc/psms1          # The sms gateway will be accessed to 'page' mobiles
        smsdone=1
        debounce=0

elif test $smsdone -eq 1        # Line 31
        then sleep 120          # Sleep for 2 minutes
        smsdone=0

elif test $result -gt 120 && test $smsdone -eq 0        # Line 35
        then debounce=$(expr $debounce + 1)
        usleep 100000
#       echo $debounce

else 
#       echo "No"                       # Line 40
        debounce=0
        usleep 100000

fi                              # Line 45

done
Not very elegant but a start.

Adrian

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#15 Post by seaside »

AdrianH,

You may find some useful material for parallel port using basic and c here-
http://basic-converter.proboards.com/th ... rt-control

Cheers,
s

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#16 Post by AdrianH »

Seaside.

Thanks for the post, I will have a general read but will not be able to use basic or C at the present, a bit outside my knowledge.

I think.I guess my next thing I will be doing is converting the decimal numbers into some sort of hex mask so I can then test individual bits.

I have access to
D3 =8
D4 =16
D5 =32
D6 =64
D7 =128

Pins D0, D1 and D2 are internal and can change on there own. In fact D0 = 1 does change from time to time.

My next major will be when I get my Alarm keyfob and relays to try, awaiting delivery from China or HK, then I will check operation and put into use, in the interim I will be trying to smarten the code up and put a few checks in to determine if the network and all the other services are up (If I can).

Adrian

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#17 Post by AdrianH »

Have done a bit more tonight on the perl script

Code: Select all

#!/bin/sh
# run try number 5
# This is a test script
# Pin resides in /bin
# Normal use is pin 0x379  where 0x379 is the status port in hex format
# Can not use port0x379 it has to have the space as the port number is a variable passed to pin
# result shpould be the response typically 120 decimal
# hope to use result as part of a if else and loop
# in run5 have done a conversion from decimal input to descrete values D7 to D0
# D3 to D0 will never get used in this application, but done for completeness
# This now means I can test  each of the upper five status bits of the status port

status=0x379	# The number for the status port
smsdone=0	# To determine if sms message has been sent
debounce=0	# A Bit of software debounce

while : 
do
#	echo "infinite loops  hit CTRL+C to stop"

result=$(/bin/pin $status)	# The result of reading the status pins # Line 21
#echo $result
x=$result
y=$(expr $x - 128)
if test $y -ge 0
	then D7=1
	x=$y
	else D7=0
fi
y=$(expr $x - 64)
if test $y -ge 0
	then D6=1
	x=$y
	else D6=0
fi
y=$(expr $x - 32)
if test $y -ge 0
	then D5=1
	x=$y
	else D5=o
fi
y=$(expr $x - 16)
if test $y -ge 0
	then D4=1
	x=$y
	else D4=0
fi
y=$(expr $x - 8)
if test $y -ge 0
	then D3=1
	x=$y
	else D3=0
fi
y=$(expr $x - 4)
if test $y -ge 0
	then D2=1
	x=$y
	else D2=0
fi
y=$(expr $x - 2)
if test $y -ge 0
	then D1=1
	x=$y
	else D1=0
fi
y=$(expr $x - 1)
if test $y -ge 0
	then D0=1
	x=$y
	else D0=0
fi
#echo "D7= "$D7			# Line 72
#echo "D6= "$D6			# Clear the #'s to see results
#echo "D5= "$D5
#echo "D4= "$D4
#echo "D3= "$D3
#echo "D2= "$D2
#echo "D1= "$D1
#echo "D0= "$D0
#echo "  "

if test $D7 -eq 1 && test $debounce -eq 5 && test $smsdone -eq 0	# Now testing the D7 bit Line 82
	then			# To be at this point, the contacts have been closed for 500 mS 
	/usr/etc/one		# And the sms gateway has not been used
	/usr/etc/psms1		# The computer emits a sequence of 'beep' musical sounds
	smsdone=1		# The sms gateway will be accessed to 'page' mobiles
	debounce=0

elif test $smsdone -eq 1	# Line 89
	then sleep 120		# Sleep for 2 minutes
	smsdone=0

elif test $D7 -eq 1 && test $smsdone -eq 0 	# Line 93
	then debounce=$(expr $debounce + 1)
	usleep 100000
#	echo $debounce

else 
#	echo "No"		# Line 99
	debounce=0
	usleep 100000

fi				# Line 102

done
This allows me to test each bit by testing D0 to D7 although I can only access D3 to D7 on the status port, it means in the future I could test for 5 different inputs

Adrian

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#18 Post by AdrianH »

Well the monitor was installed today and works, a trial run went OK.

I used amarok on a home pc at my end (suse11.4) to listen to the audio as I found this to give the least latency, I have tried puppyradio and it does work but the latency is several seconds probably due to having so much cache for audio and not being able to reduce it less then 64K, when the audio is only requiring 4K bandwidth 16 to 17 seconds is a long wait.

I will have to now get another thin client as my spare had intermittent receive audio and I now need another to play, test, improve on.

Tempted to try and have a cron job to send me a text at a set time every morning to at least let me know it is on line and functioning.

Adrian

AdrianH
Posts: 64
Joined: Thu 17 Oct 2013, 21:45
Location: Blackburn in the UK

#19 Post by AdrianH »

A bit of an update on the previous post first.

I found that command line of mplayer with the -nocache option gave as good a delay as amarok on suse. pity I do not seem to be able to remove the minimum 64 K option when in X.

Mum is currently in hospital has been since Monday so evenings and weekends have been hectic with visiting and sorting things out.

I recently got two more HP thin clients same type and as before they have 192Meg Flash and 256 Meg Ram

This equates to around 174.7 Meg after formatting and boot loader on the flash and 240 Meg ram after the video take 10 plus Meg for its use.

This is not enough for me to install Slacko Puppy the non PAE version in hardware without upgrading the memory.

I have been trying to remove as many of the applications as I can to get the size down and been doing a remastered iso. The best I managed to get down to was 157.4 Meg which I thought was not bad considering I also have a sfs file for perl provided by 01micko in there, but a frugal install, changing start-up settings etc still takes it so I have less then 3 meg of spare space on the flash and the computer is no longer reliable and dies.

I have been looking at Tinycore Linux, but Icecast, darkice, ssh server, and rsound are not available. It was Monsie that did the rsound as a pet for me.

I need to fathom if I can get rid of all the X components and just have a slacko puppy that is pure console, and then figure out if I can install pets from command line and set everything else up from CLI.

Tiny core does not have a file layout I can figure.

Adrian

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#20 Post by mikeb »

Aye up...

Space the final distro frontier.

There are some smaller pups around ... mine are more like 100MB and there are plenty of others... might save you some strip time.

From your doings there is noting particularly in need of this weeks system so an older one might be fine if smaller.

You could strip out the Xorg side of X and leave Xvesa which would save quite a bit of space but leave a desktop for setting up.
You can install command line I believe but never tried it with pets...

Another big size bunny are drivers...especially wifi and their associated firmware so big savings can be made if not needed or only one type is.

Slitaz is another small one IF it does what you want...sometimes its worth persevering with the familiar.

mike

Post Reply