Archive for the ‘Uncategorized’ Category.

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.

Brother MFC-235C and phpSANE plus Scan-to-eMail etc.

I had some challenge to get phpSANE to work with the flatbed scanner of my MFC-235C.

Although phpSANE should create a scanner ini file with the available settings of the scanner, this does not work out of the box with a simple install of phpSANE. To get the available settings of the sanner, scanimage -L is used. Using this manually reveals which SANE features are supported by the scanner:

Options specific to device `net:localhost:brother2:bus5;dev1':
  Mode:
    --mode Black & White|Gray[Error Diffusion]|True Gray|24bit Color [24bit Color]
        Select the scan mode
    --resolution 100|150|200|300|400|600|1200|2400|4800|9600dpi [200]
        Sets the resolution of the scanned image.
    --source FlatBed [FlatBed]
        Selects the scan source (such as a document-feeder).
    --brightness -50..50% (in steps of 1) [inactive]
        Controls the brightness of the acquired image.
    --contrast -50..50% (in steps of 1) [inactive]
        Controls the contrast of the acquired image.
  Geometry:
    -l 0..215.9mm (in steps of 0.0999908) [0]
        Top-left x position of scan area.
    -t 0..355.6mm (in steps of 0.0999908) [0]
        Top-left y position of scan area.
    -x 0..215.9mm (in steps of 0.0999908) [215.88]
        Width of scan-area.
    -y 0..355.6mm (in steps of 0.0999908) [355.567]
        Height of scan-area.

But most of these values are not recognized by phpSANE. So I hardcoded some of the features directly in the phpSANE code.

Fixes and changes

  • Missing directories (output, scanners, tmp), incorrect permissions prevented phpSane to create a scanner ini for the scanner.
  • The Mode selection list was not filled as phpSane expects the special mode names Gray, Color and Lineart. I hard coded the mode_list and changed security.php to allow spaces, [, ] and &
  • The pnm output of the scanimage command for the brother is corrupted. I added a pipe into pamfixtrunc in the cmd used to generate files or preview (scan.php)
  • changed config.php to meet the scanners features. I.e. the lowest res supported is 100 and not 75.
  • although scanimage says the scanner supports brightness and contrast, phpSane was unable to read the correct values. I hardcoded brightness and contrast default, min and max values (0,-50, 50).

See my code at https://github.com/hjgode/phpSANE

brscan-skey

I was unable to get the scripts provided to work with my Linux Debian installation, so I just coded some new scripts and replaced the original ones.

Here is my scan-to-email script (scantoemail-0.2.4-1.sh) using sendEmail package:

#!/bin/sh
FILENAME="/tmp/$(date "+%Y-%m-%d_%H-%M-%S").jpg"
SENDTO='nameofreceiptient@mail.com'
SCANCMD="/usr/bin/scanimage -d 'brother2:bus5;dev1' --mode 'True Gray' --resolution 150dpi -l 5mm -x 210mm -y 297mm | /usr/bin/pamfixtrunc | /usr/bin/pnmtojpeg > "$FILENAME
SENDEMAIL="/usr/bin/sendEmail -f 'yournamel@mail.com' -t "${SENDTO}" -u 'Scanned to email' -m 'Im Anhang das gescannte Dokument' -a "$FILENAME" -s 'smtp.gmail.com:587' -xu 'yourname@gmail.com' -xp 'yourepassword' -o tls=auto -o message-charset=utf-8"
eval ${SCANCMD}
eval ${SENDEMAIL}
exit 0

Fix corrupted pnm output of scanimage

Unfortunately the pnm out put of scanimage is corrupted with the MFC-235 bu can be fixed on-the-fly with the use of pamfixtrunc. This was used in my scan-to-email replacement and in my phpSANE setup.

Mobile Development: Subclass foreign Window using injectDLL

Recently we needed to show and hide the SIP (Software Input Panel) inside a full screen Remote Desktop Mobile session.

The first challenge is to control the SIP without having a menu bar with the SIP symbol inside. To get this working you can assign a hardware keyboard button, it must be an App button, to show the SIP. See Settings>Personal>Buttons and assign “<Input Panel>” to the hardware key.

app_button_to_input_panel RDM_fullscreen_option RDM_fullscreen RDM_fullscreen_with_SIP

Unfortunately the SIP will be hidden immediately after being shown if RDM is started with Full Screen option.

Continue reading ‘Mobile Development: Subclass foreign Window using injectDLL’ »

Setup XAMPP Windows as SSL/TLS server

Recently I again needed to check a browser’s SSL capabilities. So, how to setup a test server using it’s own CA? Some time ago I needed to do that previously and found several tutorials, but NONE of them work as written. Now, the same problem again: Find a working tutorial.

This time I sued the one at blog.sortedset.com although the missing images made me nervous. But all over all, the tutorial works with minor changes:

So, I first created a new VirtualBox Windows 6, x64 english test PC (IP address=192.168.0.101). Then downloaded xampp-win32.1.8.1-VC9-installer.exe and installed XAMPP. Next step was to download and install OpenSSL. I used Win32OpenSSL-1_0_1f.exe. Again got a warning about missing VS2008 VC9 runtimes and downloaded and installed that too. Then I followed the tutorial:

Continue reading ‘Setup XAMPP Windows as SSL/TLS server’ »