Interfaces that talk across multiple computers, how?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

my test

#61 Post by mister_electronico »

my test.

Open demo_2pwr.sh 2 seconds.

press key responds almost immediately.

maybe using the nice command improve it.

Is too late here I must go to the bed .

make mistake with one computer in my work, the computer I test it is:

See you tomorrow.
Attachments
cpu.png
(34.68 KiB) Downloaded 190 times

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#62 Post by starhawk »

Ah. Mine is quite wimpy in comparison.

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

#63 Post by 01micko »

starhawk,

With the latest demo_2pwr.sh edit lines 38 and 39 and change to tim=1

From cli run:

Code: Select all

 ./demo_2pwr.sh  tm
or

Code: Select all

./demo_2pwr.sh  hm
Open a new terminal and run:

Code: Select all

top -p `pidof demo_2pwr.sh`
That will tell you roughly the cpu and memory usage of the program.

Realistically, gtkdiaolog is too slow to go below a 1 s time refresh interval. I have tried 0.5 and it barely works on a smaller program, so for stability 1 s is the limitation here.

Caching the gui has brought down the cpu usage dramatically so I don't see why it wont run ok on a PIII (which is what via cpu's are more or less equivalent to).
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#64 Post by starhawk »

top keeps throwing invalid option errors :(

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

#65 Post by 01micko »

Try this

Code: Select all

pidof demo_2pwr.sh
A number should be output that is the process ID (PID) of the program.

run:

Code: Select all

top -p 1234
obviously with the number from the first command.

If pidof fails, try busybox pidof instead.
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#66 Post by starhawk »

*sigh*

Code: Select all

# pidof demo_2pwr.sh
9454
# top -p 9454
top: invalid option -- 'p'
BusyBox v1.19.3 (2011-11-09 07:34:50 WST) multi-call binary.

Usage: top [-b] [-nCOUNT] [-dSECONDS] [-m]

Provide a view of process activity in real time.
Read the status of all processes from /proc each SECONDS
and display a screenful of them.
Keys:
	N/M/P/T: show CPU usage, sort by pid/mem/cpu/time
	S: show memory
	R: reverse sort
	H: toggle threads, 1: toggle SMP
	Q,^C: exit

Options:
	-b	Batch mode
	-n N	Exit after N iterations
	-d N	Delay between updates
	-m	Same as 's' key

# top 9454
top: invalid option -- '9'
BusyBox v1.19.3 (2011-11-09 07:34:50 WST) multi-call binary.

Usage: top [-b] [-nCOUNT] [-dSECONDS] [-m]

Provide a view of process activity in real time.
Read the status of all processes from /proc each SECONDS
and display a screenful of them.
Keys:
	N/M/P/T: show CPU usage, sort by pid/mem/cpu/time
	S: show memory
	R: reverse sort
	H: toggle threads, 1: toggle SMP
	Q,^C: exit

Options:
	-b	Batch mode
	-n N	Exit after N iterations
	-d N	Delay between updates
	-m	Same as 's' key

#

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

#67 Post by 01micko »

sorry about that, I'm using real 'top'. Have you got htop? Try the previous command with that instead.
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#68 Post by starhawk »

Code: Select all

# htop
bash: htop: command not found
# 

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

#69 Post by 01micko »

:lol: .. you are just plain outa luck!

...or are you?

Save this as "pm_top" (pm="poor man's)

Code: Select all

#!/bin/sh

# pm_top
# a poor man's top

v=0.1

args=$#

usage() {
	echo "${0##*/}-$v"
	echo
	echo -e "\t${0##*/} [array of programs]\n"
	echo "eg:"
	echo -e "\t${0##*/} foo bar baz\n"
	echo ".. assuming foo, bar and baz are processes on your system."
	echo "quit with CTRL+C"
	exit
}
clear
#echo "$args args"

[ -z "$1" ] && usage

while [ 1 ];do
	z=1
	d=1
	for i in "$@";do
		pid=$(pidof $i)
		if [ -z "$pid" ];then
			echo "$i not running"
			[ $args = $d ] && echo "exiting" && exit #everything is empty
			d=$(($d + 1))
			continue
		else
			args=$((args + 1))
			pid=${pid%% *}
			echo -en "$i\tpid: $pid"
			echo
			ps -p $pid -o %cpu,%mem,cmd 2>/dev/null
			z=$(($z + 1))
		fi	
	done
	sleep 2
	clear
done
It will work best if you call it with demo_2pwr.sh and gtkdialog (as long as no other gtkdialog process is running)

eg:

Code: Select all

./pm_top gtkdialog demo_2pwr.sh
This actually overcomes a limitation of top, htop as we can show just those 2 processes at once, since they are all we are interested in.

EDITED0: to show PID
EDITED1: to ignore non-running processes
Attachments
pm_top.png
pm_top in action
(32.78 KiB) Downloaded 149 times
Last edited by 01micko on Thu 14 May 2015, 04:31, edited 2 times in total.
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#70 Post by starhawk »

Having a lot of fun here :P it just prints a boatload of blank lines and nothing ever starts.

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

#71 Post by 01micko »

well if ps is the busybox version then there is a bad bug in your puppy :cry:

What version?

BTW, edited script to show PID.

Here's how to tell:

Code: Select all

which ps-FULL
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#72 Post by starhawk »

Code: Select all

# which ps-FULL
/bin/ps-FULL
#

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

#73 Post by 01micko »

Ok, so it will work. Perhaps I didn't explain that demo_2pwr.sh must be running. :oops:
Puppy Linux Blog - contact me for access

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#74 Post by starhawk »

Aha, now it works!

[maxwellsmart]The ol' PEBCAK error trick, second time I've seen it this week![/maxwellsmart]

(If you don't get the reference... watch "Get Smart" ;) )

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

#75 Post by 01micko »

... and .. loving it!


Edited a second time to ignore mistakes/non-running-progs on the cli. If all of them are non running, the prog just dies peacefully.
Puppy Linux Blog - contact me for access

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Question?

#76 Post by mister_electronico »

The question is there any way to make the process faster than the timer gtkdialog program.

01micko said
Try this

pidof demo_2pwr.sh

run:

top -p 1234
Does this make the program go faster?
or only to appear at the top of htop.

If I do:
ps al
I see that all programs have the same priority maximum 20 PRI as you can see in the picture below.

What is burning my head is how do that gtkdialog refresh the pictures SVG faster.

It occurred to me this script to calculate the time it takes to open the gtkdialog demo_2pwr.sh program not very accurate

Code: Select all

#!/bin/sh
date
./demo_2pwr.sh &
while !( ps aux | grep -v 'grep' | grep -q 'gtkdialog'); do date ; done

time = first date - last date
Attachments
ps.png
(68.63 KiB) Downloaded 388 times

starhawk
Posts: 4906
Joined: Mon 22 Nov 2010, 06:04
Location: Everybody knows this is nowhere...

#77 Post by starhawk »

mister_e, the 'faster' question was due to a misunderstanding on my part. It's been addressed :)

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Hi starhawk

#78 Post by mister_electronico »

In this program so far no problem because only one or two images cools SVG, but when you have to refresh multiple images SVG problems begin.

Try this test program will not finish the up button - down and RST.


it have to refresh a number of images each time:

4 displays x 7-segment + 4 points = 32 SVG images.

This makes the program slow gtkdialog

I can make all the big part of the program in C, would gain in speed but still refresh process images would be slow.
Attachments
panel.png
(20.07 KiB) Downloaded 338 times
PANEL.tar.gz
(6.01 KiB) Downloaded 155 times

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

Re: Hi starhawk

#79 Post by 01micko »

mister_electronico wrote:In this program so far no problem because only one or two images cools SVG, but when you have to refresh multiple images SVG problems begin.

Try this test program will not finish the up button - down and RST.


it have to refresh a number of images each time:

4 displays x 7-segment + 4 points = 32 SVG images.

This makes the program slow gtkdialog

I can make all the big part of the program in C, would gain in speed but still refresh process images would be slow.
Yes I am afraid that the limitation in this program and my program is definitely refreshing of the images in gtkdialog. It is too slow and nothing can be done about that.

In C, instead of SVG you can use Cairo which is still a vector library but with completely different syntax. The 'images' can be held in memory, instead of writing to disk (essentially /tmp is mounted on RAM, but we still consider this 'writing to disk'). It's easy to make a structure for each type of image to make them an object.

This would significantly speed up the process. To make it even faster, you can forget GTK and just use Xlib, however Xlib programming is quite 'dangerous' and very tedious! There is not much documentation apart from reading the sources. I know, I have a couple of programs which make use of Xlib only.

--------------------------------------------------------------------------

Starhawk.

Bad news I'm afraid. I have an XO-1.5 which is a via chipset using openchrome graphics driver and the program I wrote is just too slow. It takes, - er - "some" time for the gui to show but the key presses are unresponsive. This *could* be due to the XO not having a standard keyboard, I dunno, I didn't go too far into it. It is certainly a hamstrung machine, you may have better luck on your thin clients. I suggest you rig up a test machine and go for it before we waste too much time.

Aside from that, I have significantly sped up the appearance time of the gui by changing the shell call form #!/bin/sh to #!/bin/ash.

Ash is a busybox applet but it is a full featured interactive sh environment, however does have limitations. The main one is no bashisms, which kind of means that you have a reduced syntax set. Fortunately, my original code only included 1... export -f, but unfortunately this was a biggy! gtkdialog can't 'see' a non-exported function. You have to explicitly call it.

I decided a redesign was in order; didn't take much. Just moved all functions to a functions library which can be made use of from subsequent gui programs. I also threw away about 200 lines of code... actually 20k! It doesn't speed it up much though as it was only image generation stuff.

Anyway, enough waffle - program attached.

EDIT 0:
Oh, I have also significantly changed what keys do what. There are far less actions now, only 0-9 and x, y, z. I am assuming that the bottom 2 rows are 'indicators' (idiot lights) only and as such they are not assigned any key or action. I also need to know what the hell many of these things are !!! MANF, UNSP, NO FLT ??? Should they do anything.. that is, are they 'buttons' or 'indicators'?

Again, read README.md.
Attachments
starship-pwr-gui.png
(25.62 KiB) Downloaded 356 times
starship-V6.tar.gz
bc6b70073e512104ab335b32276c71d2 starship-V6.tar.gz
(8.03 KiB) Downloaded 124 times
Puppy Linux Blog - contact me for access

User avatar
mister_electronico
Posts: 969
Joined: Sun 20 Jan 2008, 20:20
Location: Asturias_ España
Contact:

Thanks

#80 Post by mister_electronico »

Thanks 01micko for your answer

01micko

Code: Select all

It's easy to make a structure for each type of image to make them an object.
How you do that you can put a small example.

It's a shame that gtkdialog works very well in Puppy.

Post Reply