Archive for the ‘Uncategorized’ Category.

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’ »

TP-Link TD-W8961ND DSL router can not access admin web page after 24 hours or so

This is a security feature. If the Admin web page has not been accessed for some time the router disables the access completely. Router does still work, ping is OK, WLAN and WWAN connections are working, you just can not access the admin web page.

As I am running a Linux server I decided to make a hourly cron job that simply accesses the router admion web page every hour. So I can access the admin web all time without the need to cycle it’s power 🙁

I added a cron.hourly bash script to access the admin page every hour:

#!/bin/sh
wget -O - -q -t 1 --user=<adminusername> --password=<yourpassword> http://<yourrouterip>

Replace the user name, password entry and ip with the ones of your router and copy that bash shell script to /etc/cron.hourly. Don’t forget to make it executable (chmod a+x ).

Update: although the above is running the web admin page could not be reached after some days. Odd security mechanism 🙁