Windows Mobile – the no-go world of Function Keys

Hello

I want to summarize the role of function keys in Windows Mobile, former Pocket PC, as I got several questions each week on how to use or enable Function keys in this or that application.

Here is a simple information about how function keys work in Windows Mobile.

Continue reading ‘Windows Mobile – the no-go world of Function Keys’ »

Android: Print PDF to Thermal Portable Wireless Printer

Recently I got the request to write an application that prints a PDF file on a portable Thermal printer.

Normally that does not make sense, as the protable printers come with 2, 3, 4 or 5 inch paper width only. But the PDF files are created for 3 inch paper and os this Receipt printing makes sense.

The idea was to render the PDF to a bitmap and then print the bitmap to the printer. These printers do not support PDF or Postscript, they come with special Printer Language support as called ZPL, ESP/P, CPCL or others. So we need to create a Bitmap of the PDF first and then print the Bitmap.

I started using the Android Google PDFRenderer but this fails with two issues: the bitmaps created are always transparent and print with black background where white has to be; the text was not rendered as the Fonts did not render.

Among others I found PDFbox and after fixing a small issue with scaling of bitmaps the solution works very well.

The CPCL_Sample code and application can load a PDF file. This is then converted to a scaled bitmap which can then be printed to a CPCL compatible printer. The CPCL performance is very different and printing on a Zebra takes about a minute for a 3 by 4 inch sized bitmap.

The code has to use a lot of intents and background tasks as most processing takes some time. The bitmap is created by an IntentService. The Sewoo SDK prints the bitmap first to a queue buffer and there is no control or feedback about the status of the print job. So it hopefully prints after some time.

By replacing the print SDK you should be able to print the bitmap of the rendered PDF to any Bitmap-Printing capable printer.

Be warned: there are Printers that are compatible with a Printer Language like CPCL but may not support Bitmap printing.

Source code and apk at github.

FHEM: serielle Devices über Netzwerk anschliessen

Zu Testzwecken brauche ich ab und an neben meinen Haupt FHEM System ein zweites FHEM System, zB auf meinem Netbook. Nun sind drei Devices (nanoCUL 433MHz, nanoCUL 868MHz und ein Jeelink) direkt am Hauptserver über USB (serial) angeschlossen. Wenn ich diese in einem Testsystem benötige, müsste ich die Geräte vom Hauptserver trennen. Wie praktisch wäre es, wenn ich diese USB Devices über das Netzwerk anbinden könnte, so wie dies über EspLink mit dem angschlossenen Arduino Nano mit SignalDuino Firmware möglich ist.

Nun zur Anbindung von seriellen Geräten an das Netzwerk gibt es für Linux ser2net. Leider ist die Original-Version nicht multi-Client tauglich und würde nur einem Client die Verbindung erlauben. Bei EspLink sind jedoch mehrere Clients möglich. Obwohl die meisten ser2net Quellen nur einen Client unterstützen, gibt es ein oder zwei Quellen, deren Implementierung mehrer Clients unterstützen.

Nachdem ich einen Quellcode von ser2net mit multi-Client Support geladen und nach geringen Modifikationen auch erfolgreich implementieren konnte, kann ich nun alle Geräte, die am Haupt FHEM Server angeschlossen sind auch über mein Netzwerk nutzen. Die Geräte mussten nur in der ser2net conf Datei mit verschiedenen Netzwerkports eingetragen werden:

2301:raw:0:/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9YDLRJV-if00-port0:38400,8DATABITS,NONE,1STOPBIT
2302:raw:0:/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A94BBD91-if00-port0:38400,8DATABITS,NONE,1STOPBIT

In der fhem.cfg wurden die Geräte entsprechend umdefiniert:

#define nanoCUL433 CUL /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A9YDLRJV-if00-port0@38400 1234
define nanoCUL433 CUL 192.168.0.40:2301 1234
#define nanoCUL868 CUL /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A94BBD91-if00-port0@38400 3421
define nanoCUL868 CUL 192.168.0.40:2302 4321

Die original EspLink Anbindung des Arduino Nano mit SignalDuino Firmware:

define sduinoIP SIGNALduino 192.168.0.99:23

Mit diesen Änderungen kann ich diese USB Geräte nun auch über das Netzwerk benutzen.

Meine Abwandlung von ser2net findet sich auf Github.

Convert / Mogrify slow, try epeg

Recently I had a set of images to resize from 8000×10000 pixels down to 2048 pixels maximum. As previously I started with mogrify (mogrify -sample ‘2048>x2048>’ -monitor *.jpg) but it was terrible slow and slowed down my netbook to be totally unusable. Crap….

I looked for alternatives and found epeg. Download and compiled from https://github.com/mattes/epeg. After fetching libjpeg-dev and libexif-dev, it compiled without error. Finally needed to do ldconfig.

It was lightning fast and did not slow down my netbook (1GHz, 1GB, atom2 proc.). Unfortunately I had to convert file by file (i.e. epeg -v -w=2048 -h=2048 –max=2048 -p image01.jpg image01_.jpg), but that was done from a script.

If you ever look for fastest resizing give epeg a chance.

Enigma2 OpenEmbedded Enhanced Movie Center Trashfolder CleanUp

We own a great VuPlus Solo2 Linux based Satelit Receiver. We record some series and films and then delete them. The deleted media files are not deleted directly when using EMC to view and delete. The media files are moved to a trash folder first and should be automatically deleted after x days. But that does not work for whatever reason.

Recently I checked the trash folders I found, as I wondered why the box’s hard disk is getting filled up. And I found many, many old ‘deleted’ files, that are not removed from the hard disk.

I decided to write my own script (/home/root/deltrasholder7days.sh, yes, there is a typo ;-)) ) to finally remove ‘deleted’ files after 7 days. The script was then added to the root’s crontab.

#!/bin/sh
# delete old files
# delete trash files older than 7 days
/usr/bin/find /mnt/hdd/movie_trash -type f -mtime +7 -delete
/usr/bin/find /mnt/hdd/movie/trashcan -type f -mtime +7 -delete
cd /mnt/hdd/movie_trash/
rm last_cleanup*
touch last_cleanup_$( date '+%Y-%m-%d_%H-%M-%S' )
cd /mnt/hdd/movie/trashcan/
rm last_cleanup*
touch last_cleanup_$( date '+%Y-%m-%d_%H-%M-%S' )

The script deletes all files at /mnt/hdd/movie_trash and /mnt/hdd/movie/trashcan with a modification date of 7 days before current day. Then it adds a file with a timestamp as name to let me know, that the script has worked at what time.
… and the crontab (/etc/cron/crontabs/root):

1 1 * * * /home/root/deltrasholder7days.sh

This starts the script every day at 1pm.

That’s all, thank’s to the author of the find utility.