Writing script for UsbDisplay

hrust_ray

Neuer User
Mitglied seit
11 Jan 2007
Beiträge
133
Punkte für Reaktionen
0
Punkte
0
Hi.
I have 2line display and start writing script to displaying as much useful info, as possible.
Currently date and time is displayed (updated 1 time in minute)
In plans i want to display missed calls and current weather, maybe something from webtransmission client.

Maybe somebody have already such kind of scripts and be so kind to share them?

My question is following: How I can give ESC (dec 27) code in echo command to use escape control sequences?

MFG
 
Try one of these ...
Code:
esc=`echo '\e'`
esc=`echo '\033'`
after which $esc should contain the escape-character ... didn't test though :)

Regards
dynamic
 
The following works:

echo -e "\033"

-e enables escape sequences, while in bash this is disabled by default
 
Is it possible to display calls received? Where is stored this info?
 
I tested script for displaying time and found, that it works apprx 4 hours and then FB reboots.
So, question. command "echo sometext > /var/ttyUSB0" can overflow memory after some time? Maybe file /var/ttyUSB0 becomes bigger and bigger after each echo command?
This is crazy idea, but I try to explain why FB reboots.
 
Hi.
/var/ttyUSB0 should be an character device, pipe or something similar. So no RAM is needed by this. Perhaps you can attach some log file?

Greets Oliver
 
Hm. After FB is rebooted no logfiles any more.
U mean dmesg logs?
 
Can U please give some advice?
I trying to parse file with information about weather - so I need to extrach some substring.
Unfortunately command 'expr' is not present in FB bash.
How can I extract substring in other way?
 
Hello hrust_ray,

sorry, I don't know how to extract substing in other way. But you can download a busybox with expr from here http://www.ip-phone-forum.de/showpost.php?p=807953&postcount=32 (click on "Versuch mal hier") and copy it to your FB (to /var/tmp or to usb-stick) and call it with "/var/tmp/busybox expr"...

Best regards, Reiner
 
Thanks! Full busybox will be very useful.

Btw, Yesterday I change script for displaying time - now it update screen each 30sec(previosly it was 1 sec and after 4hrs FB made selfreboot). New script works for 10 hrs without problems.
 
Hello hrust_ray,

sorry, I don't know how to extract substing in other way. But you can download a busybox with expr from here http://www.ip-phone-forum.de/showpost.php?p=807953&postcount=32 (click on "Versuch mal hier") and copy it to your FB (to /var/tmp or to usb-stick) and call it with "/var/tmp/busybox expr"...

Best regards, Reiner

Dummy frage. Can I found somewhere executable for command 'expr' without busybox? Because busybox takes 500kb and it cannot be copied to /var/
 
Hello hrust_ray,
german's not easy (english also not for me), I think you want to say "Dumme Frage"? Another german saying goes "There are no stupid questions, there are only stupid answers...".
But back to the question. I think it must be possible to generate a smaller busybox with only funktions which are missing in original busybox (or only one funktion, this will be usefull for people, who only want to extend orginal firmware), but up to now no one did it (or I did not find it). I also only downloaded this binary and my 7170 has enough memory, so up to now, there was no need to do it...
You could copy the binary to a USB-Stick and start it from there, but I fear this will not solve the problem because when you start it, the program must be loaded into memory (on my box a first start of this busybox (from USB-Stick) need 780 KB).
But perhaps this is your problem that you don't have enough memory? This may be a reason for your rebooting problem, FB reboots when memory is out. I also use a USB->serial Adapter (pl2303), all driver and programs on USB-stick and have no problem with it. I have at least 3 MB free memory on 7170 (free an buffers values added on free-programm-output).

Best regards, Reiner
 
rusmueller, are U russian? :) I am.

I also have pl2303 adapter and it works with drivers, placed on USB - stick.
But now I'm afraid to give too much memory for only one command ('expr' or another one, that will cut substring from file content).
If busybox will be placed to memory each time before command execution and after it is executed, memory will freed - that can work. Because I plan to update weather once a day. But also webtransmission running on FB, so free 500kb cannot be guaranteed.
What I think also: possibility to extract substring to parse text files or variables is very useful for many tasks with FB. And I wonder why there is no some possibility to do it without loading 500rb module to memory.
rusmueller, what for U use your display?
 
rusmueller, are U russian? :) I am.
rusmueller = Reiner and (german und) Susanne Mueller...
But now I'm afraid to give too much memory for only one command...
Yes, I understand, you can use ds-mod (freetz) I think this busybox includes expr. You can also remove parts of software you don't need, to increase free memory. Or you can solve your problem with sed? Sorry, I'm not familiar with it.
what for U use your display?
I use some external microcontroller (C-Control and AtMega) for home controlling, playing and learning.
 
There are many functions in the bourne-shell that allow string chopping/padding/delimiting.

What is the pattern of your input and output strings ?
 
F.e. I download html file with weather using wget. There is something like this inside file:

Regionalwetter
Roding


{:: Vorhersage} {:: Biowetter} {:: Straßenwetter}
{:: >2 Stunden}< {:: Pollenflug} {:: Kratzprognose}
{:: Mittelfrist} {:: UV/Ozon} {:: Cabriowetter}
{:: Langfrist} {:: Garten/Agrar} {:: Wind}
{:: akt. Meldungen} {:: Kameras} {:: Badeseen}


Donnerstag, 7.2.2008

Vormittags ist der Himmel bei 0 Grad meist grau, auch am Nachmittag meist dicht bewölkt bei 1 Grad. In der Nacht ist es wechselnd bewölkt bei Werten um -2 Grad.
Mittag Nachmittag Abend Nacht
[bedeckt] [bedeckt] [wolkig] [bewölkt]
1°C 1°C 0°C -2°C

So I want to extract values of temperature for Mittag, Nachmittag and also weather type (bedeckt, wolking...)
My main problem is how to extract some data using regular expressions for example and put this extracted data to variable. Then I can form string for dislaying, using this variables
 
The two examples below expect as input:
1) 4 "space" separated" strings, that are embedded in "[ ]"
2) 4 "space" separated strings, that are followed by "°C"

The "\4" at the end would print the 4'th string, or "\2", the second string respectively etc.

Code:
echo "[clowdy] [snowing] [raining] [sunny]" | sed "s,^\(\[.*\]\) \(\[.*\]\) \(\[.*\]\) \(\[.*\]\),\4,"
echo "1°C 1°C 0°C -2°C" | sed "s,^\(.*°C\) \(.*°C\) \(.*°C\) \(.*°C\),\2,"
 
Zuletzt bearbeitet:
dynamic, Thnx. This is working.
I tried to do same thing directly with file ( cat filename.tmp | sed "s,.... )
in result I see founded value, but after this comes all other lines of file. Is it possible to find once the result value and store it to variable?

Then I got real file, I want to parse. It looks so:
<td width="4" class="f_10"></td>
<td bgcolor="#5282C6" class="f_10" align="center">Mittag</td>
<td bgcolor="#5282C6" class="f_10" align="center">Nachmittag</td>
<td bgcolor="#5282C6" class="f_10" align="center">Abend</td>
<td bgcolor="#5282C6" class="f_10" align="center">Nacht</td>
</tr><tr><td></td>
<td><img src="/images/wetsym_4.gif" alt="bedeckt" width="60" height="43"></td>
<td><img src="/images/wetsym_4.gif" alt="bedeckt" width="60" height="43"></td>
<td><img src="/images/wetsym_3.gif" alt="wolkig" width="60" height="43"></td>
<td><img src="/images/wetsym_n3.gif" alt="bewцlkt" width="60" height="43"></td>
</tr><tr><td class="f_10"></td>
<td bgcolor="#FFF384" class="f_10" align="center">1&deg;C</td>
<td bgcolor="#FFF384" class="f_10" align="center">1&deg;C</td>
<td bgcolor="#FFF384" class="f_10" align="center">0&deg;C</td>
<td bgcolor="#FFF384" class="f_10" align="center">-2&deg;C</td>

I modified sed command to get value
alt="bedeckt" width=
in following way

cat ./temp.tmp | sed "s,^\(alt*width\),\1,"
nothing was founded - simply all lines of file are printed out
Where is my mistake?

Thnx
 
@hrust_ray
Your second example input file is totally different from your first one ... if there is no repeating pattern ( I don't see any pattern between your first and second example ), you better forget about regex.

Search on google for "regexbuddy" - there you can find a regex "interpreter" and a lot of explanations on regex.
 
Can this be a repeating pattern?
<td><img src="/images/wetsym_?.gif" alt="bedeckt" width="60" height="43"></td>
 
Holen Sie sich 3CX - völlig kostenlos!
Verbinden Sie Ihr Team und Ihre Kunden Telefonie Livechat Videokonferenzen

Gehostet oder selbst-verwaltet. Für bis zu 10 Nutzer dauerhaft kostenlos. Keine Kreditkartendetails erforderlich. Ohne Risiko testen.

3CX
Für diese E-Mail-Adresse besteht bereits ein 3CX-Konto. Sie werden zum Kundenportal weitergeleitet, wo Sie sich anmelden oder Ihr Passwort zurücksetzen können, falls Sie dieses vergessen haben.