Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

Saturday, 23 February 2008

ACPI and WiFi card Intel PROWireless on Asus M5200ae M5A

In this post tweaking wireless card Intel PROWireless 2200 is described. It is a little bit tricky to get such card to work on Asus M5200AE notebook. But using latest extras from acpi4asus project, my wifi card works perfectly.


Intel PRO/Wireless 2200
Because this adapter is made by Intel, no problems should appear during installation of the drivers. It is required to download the firmware from here, unpack it and copy to /usr/share/firmware

Also you must install the packages for wireless networking:

aptitude install wireless-tools, kwifimanager, kwirelessmonitor-net kwirelessmonitor kwrapper
And also install packages for ACPI:
aptitude install acpi-support acpid laptop-mode-tools
If all steps were performed correctly then during boot process should be such strings:
ieee80211_crypt: registered algorithm 'NULL'
ieee80211: 802.11 data/management/control stack, 1.1.14
ieee80211: Copyright (C) 2004-2005 Intel Corporation
ipw2200: Intel(R) PRO/Wireless 2200/2915 Network Driver, 1.1.3dmprq
ipw2200: Copyright(c) 2003-2006 Intel Corporation
ACPI: PCI Interrupt 0000:01:05.0[A] -> GSI 18 (level, low) -> IRQ 17
ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
ipw2200: Radio Frequency Kill Switch is On:
Kill switch must be turned off for wireless networking to work.
ipw2200: Detected geography ZZM (11 802.11bg channels, 0 802.11a channels)
It seems to work, but there are suspicious string emphasized by red bold font. What is a "Kill Switch" and why you can not connect to wireless networks when it activated?

Radio frequency killer
There is a combination of keys that turns on and off a radio transmitter of the WIFI chip. Such combination is often mentioned as "Kill Switch", thus is you did not deactivated such kill switch then yours WiFi ciph is turned off and nothing can help you.

To test Kill Switch is on or off, you can type such command:
# cat /sys/bus/pci/drivers/ipw2200/0000\:01\:05.0/rf_kill
2
According to the documentation we have:
rf_kill
read -
0 = RF kill not enabled (radio on)
1 = SW based RF kill active (radio off)
2 = HW based RF kill active (radio off)
3 = Both HW and SW RF kill active (radio off)

End of story: Kill Switch is on, Wifi's radio transmitter is turned off. It also can be checked by iwconfig:

eth3 radio off ESSID:"virens"
Mode:Ad-Hoc Frequency:2.412 GHz Cell: Not-Associated
Bit Rate:0 kb/s Tx-Power=off Sensitivity=8/0
Retry limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

As usual, Kill Switch key combination on notebooks is Fn+F2 but on your notebook it may be different.

For the key combination to turn on you need to activate ACPI extras for your notebook. For Asus laptops it is Asus Extras. You need to obtain latest version of the asus_extras driver from SVN of the Acpi4Asus project.
For those who compiled the kernel by themselves, here are some guidelines:

Power management options (ACPI, APM) --->
[*] Power Management support ---->
[*] ACPI Support:
<М> AC Adapter
<М> Battery
<М> Button
<М> Video
<М> Fan
<М>Processor
<М>Thermal Zone
< > ASUS/Medion Laptop Extras
<--- TURN OT OFF!
Next, turning on the support of a Radio Frequency Kill Switch

Networking --->
[*] Networking support -->
Improved wireless configuration API
--- Wireless extensions
<М> Generic IEEE 802.11 Networking Stack (mac80211)
[ ] Enable debugging output
<М>Generic IEEE 802.11 Networking Stack
[ ] Enable full debugging output
--- IEEE 802.11 WEP encryption (802.1x)
<М> IEEE 802.11i CCMP support
<М> IEEE 802.11i TKIP encryption
<М> Software MAC add-on to the IEEE 802.11 networking stack
[ ] Enable full debugging output

In the Networking section turn on:
<*> RF switch subsystem support --->
<*> Input layer to RF switch connector
It is certainly that you need the NAT for providing Internet connections from you laptop, thus you need to activate NAT and Masquerading:

Networking --->
[*] Networking support -->
Networking options --->
[*] Network packet filtering framework (Netfilter) --->
Core Netfilter Configuration --->

<*> Netfilter netlink interface
...
<*> Netfilter connection tracking support

IP: Netfilter Configuration --->
<*> IPv4 connection tracking support (required for NAT)
[*] proc/sysctl compatibility with old connection tracking
<*> IP tables support (required for filtering/masq/NAT)
<*> IP range match support
<*> TOS match support
<*> recent match support
<*> ECN match support
<*> AH match support
<*> TTL match support
<*> Owner match support
<*> address type match support
<*> Packet filtering
<*> REJECT target support
<*> LOG target support
<*> ULOG target support
<*> Full NAT
<*> MASQUERADE target support
<*> REDIRECT target support
<*> NETMAP target support
<*> SAME target support
...
<*> Packet mangling
<*> TOS target support
<*> ECN target support
<*> TTL target support

Next thing to do is activation of the wireless card.

Device Drivers ---->
Network device support --->
[*] Network device support
.................
Wireless LAN --->

[*] Wireless LAN (IEEE 802.11)
<М> Intel PRO/Wireless 2200BG and 2915ABG Network Connection
<------- this is our driver, let's compile it as a module
[*] Enable promiscuous mode
--- Enable radiotap format 802.11 raw packet support
[*] Enable creation of a RF radiotap promiscuous interface
[*] Enable QoS support
[*] Enable full debugging output in IPW2200 module.


Enabling firmware load:
Device Drivers ---->
Generic Driver Options ---->
Hotplug firmware loading support

For the connection to be encrypted you need to turn on encryption support:

Cryptographic options ->
<*>ARC4 cipher algorithm
<*>Michael MIC keyed digest algorithm
<*>AES cipher algorithms (i586)

And also this one:
Library routines ->
<*>CRC32 functions


After all you need to turn on the LED's support for indication of a wireless status. In the Device Drivers section:

Device Drivers ---->
LED devices --->
[*] LED Support
<*> LED Class Support
--- LED drivers
--- LED Triggers

That's all; compile the kernel and reboot with it.

Let's fire up!
It is practically all that needed for your wireless happiness. During the boot process our kernel must detect the wireless card and turn it on. Now press Fn+F2 and the WiFi LED must turn on. If it works then all is done correctly and WiFi now can be used. Let's check the state of Kill Switch:
# cat /sys/bus/pci/drivers/ipw2200/0000\:01\:05.0/rf_kill
0
That's it, the radio is turned ON. Now type:
# iwconfig
lo no wireless extensions.

eth1 no wireless extensions.

Warning: Driver for device eth3 has been compiled with version 22
of Wireless Extension, while this program supports up to version 20.
Some things may be broken...

eth3 unassociated ESSID:"virens"
Mode:Ad-Hoc Frequency=2.412 GHz Cell: Not-Associated
Bit Rate:0 kb/s Tx-Power=20 dBm Sensitivity=8/0
Retry limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
It works! The rest of the job is simple: just configure an ad-hoc network. For the network to be configured you need to edit /etc/network/interfaces like this:

auto eth3
iface eth3 inet static
address 10.106.146.1
netmask 255.255.255.0
wireless-mode ad-hoc
wireless-channel 1
wireless-rate auto
wireless-essid virens

Now let's tweak network card:
iwconfig eth3 mode Ad-Hoc channel 1 essid virens
That's all and you got simple ad-hoc network with identifier virens .
Read more...

Saturday, 12 January 2008

Disk burning errors and some workarounds

Sometimes in a process of disk recording errors are happening. Such discs are often being threw away, but there are some tricks to finish the recording process. After that, disc is passing MD5 check and reads normally. Below are mentioned several tricks to do so.


Error during start or in the middle of recording
It is rarely happens, but at he beginning or in the middle of recording process growisofs suddenly broking precess and message appears:

Executing 'builtin_dd if=1.iso of=/dev/cdrom obs=32k seek=0'
/dev/cdrom: "Current Write Speed" is 16.4x1352KBps.
          0/4393730048 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU   0.0%
          0/4393730048 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU   0.0%
          0/4393730048 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU   0.0%
          0/4393730048 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU   0.0%
          0/4393730048 ( 0.0%) @0x, remaining ??:?? RBU 100.0% UBU   0.0%
    1671168/4393730048 ( 0.0%) @0.4x, remaining 1007:27 RBU 100.0% UBU   1.9%
:-[ WRITE@LBA=330h failed with SK=3h/ASC=0Ch/ACQ=00h]: Input/output error
:-( write failed: Input/output error
/dev/cdrom: flushing cache
/dev/cdrom: closing track
:-[ CLOSE TRACK failed with SK=3h/ASC=0Ch/ACQ=00h]: Input/output error
/dev/cdrom: closing session
/dev/cdrom: reloading tray


All that you need is to start burning again: growisofs restarts the process of recording from the last informational sector and will have record disc completely. After that, disc can be read without any problems and it passes MD5 check.


Close session error
Disk had been fully recorded, but I/O error appears while closing the session:

2144544*2KB out @ average 9.9x1352KBps
/dev/cdrom: flushing cache
/dev/cdrom: closing track
/dev/cdrom: closing session
:-[ CLOSE SESSION failed with SK=5h/ASC=72h/ACQ=03h]: Input/output error


It is pity, that disc had been burned completely but session isn't closed. Such disc is unreadable. But that can be corrected using simple trick from authors of dvd+rw-tools: here is a little program close, and here is the source code. Downloading it from here, installing sources of  dvd+rw-tools and copying close.cpp in the directory with dvd+rw-tools sources. After that, let's compile close.cpp :

g++ -o close close.cpp
Don't forget to give it appropriate permissions, and insert disc with unclosed session in the drive. Close session by command:
close /dev/hda
If you DVD-recorder have different device file than /dev/hda please correct it.
Read more...

Sunday, 6 January 2008

TV Tuner Beholder BeholdTV 409FM in Linux

For TV Tuner to work in Linux properly, several steps should be performed. Described steps below are suitable for other devices of such type: for example, webcams. Only kernel modules parameters will be different.


Tweaking TV Tuner in Debian Linux

If you are using default distribution kernel, this section is certain can skipped. Type in terminal dmesg and there should appear something like that::

saa7130/34: v4l2 driver version 0.2.14 loaded
ACPI: PCI Interrupt 0000:06:02.0[A] -> GSI 18 (level, low) -> IRQ 18

saa7133[0]: found at 0000:06:02.0, rev: 240, irq: 18, latency: 32, mmio: 0xdfeff800

saa7133[0]: subsystem: 0000:4091, board: Beholder BeholdTV 409 FM [card=67,autodetected]

saa7133[0]: board init: gpio is c0c000

input: saa7134 IR (Beholder BeholdTV 4 as /class/input/input3

saa7133[0]: i2c eeprom 00: 00 00 91 40 54 20 00 00 00 00 00 00 00 00 00 01

saa7133[0]: i2c eeprom 10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

saa7133[0]: i2c eeprom 70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

tuner 1-0060: All bytes are equal. It is not a TEA5767

tuner 1-0060: chip found @ 0xc0 (saa7133[0])

tuner 1-0060: type set to 38 (Philips PAL/SECAM multi (FM1216ME MK3))

tda9887 1-0043: chip found @ 0x86 (saa7133[0])

saa7133[0]: registered device video0 [v4l2]

saa7133[0]: registered device vbi0

saa7133[0]: registered device radio0
You can receive different diagnostic messages, but principle is the same:
  • Driver name - saa7133
  • Tuner name - Beholder BeholdTV 409 FM and card number card=67
  • Driver number for  tuner 1-0060: type set to 38 (Philips PAL/SECAM multi (FM1216ME MK3))
Thus, this numbers should be remembered or written. By default, a PAL standard is set for TV Tuners. To tell kernel module proper parameters, one must reload them with proper settings:
rmmod saa7134
modprobe saa7134 tuner=63 card=67

rmmod tda9887

modprobe tda9887 secam=d

chmod 777 /dev/video0
Greyed line is suitable only for countries with SECAM TV standard (for example, Russia).
This example covers Behold 409FM and kernel version below 2.6.18. For newer kernels (version > 2.6.18), one should use that parameters:

rmmod saa7134
modprobe saa7134 tuner=63 card=67

rmmod tuner

modprobe tuner secam=d

chmod 777 /dev/video0

Please pay attention that in /dev/ should appear new device file
video0 - here is our tuner, and this device file will be used by programs. Often many problems arise with incorrect (mostly, insufficient) permissions to /dev/video0. Thus, give maximum permissions to file:
sudo chmod 777 /dev/video0

If you have a customized linux kernel
In customized kernel, an I2C and Video4Linux support must be activated and a driver for TV Tuner chip as well. It is notable that one kernel module supports a couple of tuners!

Hence, let's compile i2c and
Video4Linux monolithically, and I2C drivers and tuner driver as modules. If you are uncertain of which driver is necessary, use
lspci
Moreover, in Documentation section of kernel sources, video4linux subsection, practically all driver parameters are described.


If TV Tuner does not work under Linux...
Consult with current kernel documentation - there should be answer of which tuners are supported. Consider to upgrade your kernel to fresh one. On the off-chance, documentation on kernel is located here: /usr/src/linux-2.6.zz.z/Documentation/video4linux where zz.z is your exact kernel version.

Inside this directory,
should be several files like CARDLIST.yyy, where yyy - driver name. Open this files and search you tuner name. If you can't find your tuner there, upgrade the kernel.

If you are lucky, you can find even a card number - for my Beholder409 it is:
./video4linux/CARDLIST.saa7134

...
67 -> Beholder BeholdTV 409 FM [0000:4091]
...
This is exact card number, just substitute it in command
modprobe saa7134 tuner=63 card=67

The same situation appears with CARDLIST.tuner - it must be only one, but this file contents tuners number. In dmesg output you should see:
tuner 1-0043: chip found @ 0x86 (saa7133[0])
tda9887 1-0043: tda988[5/6/7] found @ 0x43 (tuner)
tuner 1-0060: All bytes are equal. It is not a TEA5767
tuner 1-0060: chip found @ 0xc0 (saa7133[0])
tuner 1-0060: type set to 38 (Philips PAL/SECAM multi (FM1216ME MK3))
Hence, 38 is my tuner number (again, for Beholder409). The same number is in file:
tuner=38 - Philips PAL/SECAM multi (FM1216ME MK3)

Searching TV channels
I hope that your tuner is detected, so the only thing remaining is to install software:
aptitude install tvtime
This is one of the coolest program for TV Tuners that stood out from the rest of programs (tvtime, xawtv, zapper). After installation of tvtime, let's search channels:
tvtime-scanner
which starting to scan all frequencies and search TV channels:
Reading configuration from /etc/tvtime/tvtime.xml
Reading configuration from /home/penta4/.tvtime/tvtime.xml
Scanning using TV standard SECAM.
Scanning from 44,00 MHz to 958,00 MHz.
Found a channel at 59,50 MHz (58,25 - 60,50 MHz), adding to channel list.
Found a channel at 63,00 MHz (62,75 - 63,00 MHz), adding to channel list.
Found a channel at 77,50 MHz (77,25 - 77,50 MHz), adding to channel list.
Found a channel at 79,75 MHz (79,50 - 79,75 MHz), adding to channel list.
Found a channel at 85,50 MHz (84,25 - 86,50 MHz), adding to channel list.
Found a channel at 111,50 MHz (110,25 - 112,50 MHz), adding to channel list.

After that, run tvtime and rearrange found channels to your own taste
.
Take a note that computer TV Tuners (especially internal) are known to provide worse picture quality and less channels than conventional TV. This is caused by strong electromagnetic noise and cross-talks inside computer.
As a result, in your home directory should appear hidden directory .tvtime where all TV tweaks are placed.

Read more...

Saturday, 15 December 2007

GPRS in Debian GNU/Linux with mobile phone Siemens ME45

Problem: connect to the Internet via mobile phone and GPRS using USB-adapter Prolific PL2303 under Linux.
Solve: there are enough tools in Debian to do so.


What we have
All above mentioned will have show in my notebook Asus M5200AE under Debian GNU/Linux and Siemens ME45, adapter and local Beeline cellphone provider.


Before starting
For work to be done, PPP in kernel is required:

Networking options->
TCP/IP networking ->
Network device ->
PPP (point-to-point protocol) support

monolith or as module. Besides it, in kernel support of phone link adapter must be activated:
USB support->
Support for USB ->
USB Serial Converter support->
USB Serial Converter support
[m] USB Generic Serial Driver
[m] USB Prolific 2303 Single Port Serial Driver
If this is done, plug phone link USB adapter into USB and look at logs:
usb 3-1: new full speed USB device using uhci_hcd and address 3
drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
pl2303 3-1:1.0: pl2303 converter detected
usb 3-1: pl2303 converter now attached to ttyUSB0
usbcore: registered new driver pl2303
drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver

That's all, adapter is found and recognized by kernel, new port /dev/ttyUSB0 which will be pointed to dial program.


Tune GPRS

Only thing to do is to point to dialer right parameters, and one can use GPRS without problems. Gaining root privileges and go to /etc/ppp/peers/ to create file beeline with following contents:
/dev/ttyUSB0
57600
noauth
defaultroute
usepeerdns
persist
noipdefault
lock
connect '/usr/sbin/chat -v -f /etc/chatscripts/beeline-connect'
novjccomp
nopcomp
noaccomp
noipdefault
nodeflate
novj
Don't set too big speed of connection, it can be cause of connection breakage. One more file, beeline-connect, one ought to make in directory /etc/chatscripts/ and write in it:
TIMEOUT 45
ABORT 'NO ANSWER'
ABORT 'BUSY'
ABORT 'NO CARRIER'
SAY 'Starting GPRS connection\n'
ABORT ERROR
"" 'ATZ'
"" 'ATE1'
OK AT+CGDCONT=1,"IP","internet.beeline.ru"
OK ATD*99***1#
CONNECT c
If you use different operator, change the line AT+CGDCONT=1,"IP","internet.beeline.ru" to that which is written on a website of you cellphone provider.


Connecting to the Internet via GPRS
All necessary tweaks are done and now one can use GPRS in Linux - let's enter the command from root:
pppd call beeline
or
pon beeline
A few seconds of waiting and it is possible to work as usual:



To disconnect from the internet, type:
killall pppd
or
poff beeline
That's all.


If something goes wrong...
Not everything can be done from first trying, and if GRPS doesn't work properly, you must look up in logs, and concretely - /var/log/syslog. This file in being red only root, so gaining root privileges and reading logs:

Aug 14 08:30:37 localhost chat[7715]: timeout set to 45 seconds
Aug 14 08:30:37 localhost chat[7715]: abort on (NO ANSWER)
Aug 14 08:30:37 localhost chat[7715]: abort on (BUSY)
Aug 14 08:30:37 localhost chat[7715]: abort on (NO CARRIER)
Aug 14 08:30:37 localhost chat[7715]: abort on (ERROR)
Aug 14 08:30:37 localhost chat[7715]: send (ATZ^M)
Aug 14 08:30:37 localhost chat[7715]: send (ATE1^M)
Aug 14 08:30:37 localhost chat[7715]: expect (OK)
Aug 14 08:30:37 localhost chat[7715]: g^?ATZ^MAT^M
Aug 14 08:30:37 localhost chat[7715]: OK
Aug 14 08:30:37 localhost chat[7715]: -- got it
Aug 14 08:30:37 localhost chat[7715]: send (AT+CGDCONT=1,"IP","internet.beeline.ru"^M)
Aug 14 08:30:38 localhost chat[7715]: expect (OK)
Aug 14 08:30:38 localhost chat[7715]: ^M
Aug 14 08:30:38 localhost chat[7715]: EAT+CGDCONT=1,"IP","internet.beeline.ru"^M^M
Aug 14 08:30:38 localhost chat[7715]: OK
Aug 14 08:30:38 localhost chat[7715]: -- got it
Aug 14 08:30:38 localhost chat[7715]: send (ATD*99***1#^M)
Aug 14 08:30:38 localhost chat[7715]: expect (CONNECT)
Aug 14 08:30:38 localhost chat[7715]: ^M
Aug 14 08:30:38 localhost chat[7715]: ATD*99***1#^M^M
Aug 14 08:30:38 localhost chat[7715]: CONNECT
Aug 14 08:30:38 localhost chat[7715]: -- got it
Aug 14 08:30:38 localhost chat[7715]: send (c^M)
Aug 14 08:30:38 localhost pppd[7314]: Serial connection established.
Aug 14 08:30:38 localhost pppd[7314]: Using interface ppp0
Aug 14 08:30:38 localhost pppd[7314]: Connect: ppp0 <--> /dev/ttyUSB0
Aug 14 08:30:41 localhost pppd[7314]: PAP authentication succeeded
Aug 14 08:30:44 localhost pppd[7314]: Cannot determine ethernet address for proxy ARP
Aug 14 08:30:44 localhost pppd[7314]: local IP address 10.0.103.11
Aug 14 08:30:44 localhost pppd[7314]: remote IP address 192.168.254.254
Aug 14 08:30:44 localhost pppd[7314]: primary DNS address 217.118.66.243
Aug 14 08:30:44 localhost pppd[7314]: secondary DNS address 217.118.66.244

After that strings I gained network interface ppp0

notebeast:/home/beast# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:84 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5483 (5.3 KiB) TX bytes:5483 (5.3 KiB)

ppp0 Link encap:Point-to-Point Protocol
inet addr:10.1.193.83 P-t-P:192.168.254.254 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:204 errors:0 dropped:0 overruns:0 frame:0
TX packets:273 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:109516 (106.9 KiB) TX bytes:27628 (26.9 KiB)

through which Internet is being shed like a broad river.
Read more...

Wednesday, 12 December 2007

Long-time remote shooting with Canon EOS 400D

Problem: Shooting with exposure times 30 and more is required and this process must be automated.
Solve: using soldering iron, common chips and bash script in Linux, it is possible to make PC-driven remote control device.


What we have
We have Canon EOS 400D, Debian-powered notebook and necessity of shooting pictures with exposure longer than 30 seconds. There is good scheme proposed by Michael A. Covington here. Anyway, mirroring it here:


Pretty good scheme, but it doesn't work for Canon EOS 400D - shutter will lift up bot not down.

Scheme for Canon EOS 400D
After some fruitless trying, I am with my colleague Alexey Ropyanoi, found out why proposed scheme not work and propose new one:


And it works! Our laboratory Canon EOS 400D begin open and close shutter by computer command.

Necessary electric components
To do the same remote shooting wire, you need 4-wire cable (from audio devices or from telephone cable), 2.5mm jack (or 3/32 inch jack), mentioned in scheme chips, 9-pin COM-port and USB-COM adapter (for using this remote shooting wire on novel computers).

The best USB-COM adapter is on Profilic 2303 chip - it is the most common chip and it works in Linux, like practically all, "out of the box".


Software
For remote control of camera, little program on C is needed. It is setSerialSignal and it source code is placed here. It can be compiled with GCC, which is part of any UNIX-like OS distribution.

gcc -o setSerialSignal setSerialSignal.c
Works on Debian GNU/Linux v4.0 r.0 "Etch", gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21).

This is the code:

/*
* setSerialSignal v0.1 9/13/01
* www.embeddedlinuxinterfacing.com
*
*
* The original location of this source is
* http://www.embeddedlinuxinterfacing.com/chapters/06/setSerialSignal.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* setSerialSignal
* setSerialSignal sets the DTR and RTS serial port control signals.
* This program queries the serial port status then sets or clears
* the DTR or RTS bits based on user supplied command line setting.
*
* setSerialSignal clears the HUPCL bit. With the HUPCL bit set,
* when you close the serial port, the Linux serial port driver
* will drop DTR (assertion level 1, negative RS-232 voltage). By
* clearing the HUPCL bit, the serial port driver leaves the
* assertion level of DTR alone when the port is closed.
*/

/*
gcc -o setSerialSignal setSerialSignal.c
*/


#include
#include
#include

/* we need a termios structure to clear the HUPCL bit */
struct termios tio;

int main(int argc, char *argv[])
{
int fd;
int status;

if (argc != 4)
{
printf("Usage: setSerialSignal port DTR RTS\n");
printf("Usage: setSerialSignal /dev/ttyS0|/dev/ttyS1 0|1 0|1\n");
exit( 1 );
}

if ((fd = open(argv[1],O_RDWR)) < 0)
{
printf("Couldn't open %s\n",argv[1]);
exit(1);
}
tcgetattr(fd, &tio); /* get the termio information */
tio.c_cflag &= ~HUPCL; /* clear the HUPCL bit */
tcsetattr(fd, TCSANOW, &tio); /* set the termio information */

ioctl(fd, TIOCMGET, &status); /* get the serial port status */

if ( argv[2][0] == '1' ) /* set the DTR line */
status &= ~TIOCM_DTR;
else
status |= TIOCM_DTR;

if ( argv[3][0] == '1' ) /* set the RTS line */
status &= ~TIOCM_RTS;
else
status |= TIOCM_RTS;

ioctl(fd, TIOCMSET, &status); /* set the serial port status */

close(fd); /* close the device file */
}



Sending signals
Compiling program and making it executable, and below listed signals which will open and close shutter:

DTR
setSerialSignal /dev/ttyS0 1 0



Clear DTR
setSerialSignal /dev/ttyS0 0 0


RTS
setSerialSignal /dev/ttyS0 0 1


Clear RTS
setSerialSignal /dev/ttyS0 1 1


Shutter opens at DTR and closes at RTS.


Shell script for remote shooting
Next, it is comfortable to use bash script by Eugeni Romas aka BrainBug, but for Canon 400D script was edited and here it is:

#!/bin/bash

for i in `seq $3`; do
{
setSerialSignal /dev/ttyUSB0 0 0 &&
sleep $1 && setSerialSignal /dev/ttyUSB0 0 1 &&
sleep 0.3 && setSerialSignal /dev/ttyUSB0 0 0 &&
sleep $2 && setSerialSignal /dev/ttyUSB0 1 1 && echo "One more image captured!" &&
sleep $4;

}
done

echo "Done!"

Script parameters:
1: shutter opening delay
2: exposure time in seconds
3: amount of shots
4: delay between shots

Example:
make_captures 4 60 30 2

Script is written to work with USB-COM adaptor, and you need to edit it if you have different port.

How it works
Remote shooting wire is ready, inserting USB-COM adapter with wire and next:
  • Turn on camera, setting BULB mode, setting aperture size and ISO speed.
  • Inserting jack into the camera, another and in COM-USB adapter and then in USB-port.
  • Looking at logs: kernel must recognize chip and write something like this:
usb 2-1: new full speed USB device using uhci_hcd and address 2
usb 2-1: configuration #1 chosen from 1 choice
drivers/usb/serial/usb-serial.c: USB Serial support registered for pl2303
pl2303 2-1:1.0: pl2303 converter detected
usb 2-1: pl2303 converter now attached to ttyUSB0
usbcore: registered new interface driver pl2303
drivers/usb/serial/pl2303.c: Prolific PL2303 USB to serial adaptor driver
  • Now shoot:
    make_capture 1 5 2 3
Here we make 2 images with 5 second exposure, delay between shots is 3 seconds, delay for shutter lifting 1 second.

Acknowledgements
I would like to express my gratitude to:
  • Michael A. Covington for his original article "Building a Cable Release and Serial-Port Cable for the Canon EOS 300D Digital Rebel".
  • Eugeni Romas aka BrainBug for link to original post and discussion.
  • Anton aka NTRNO for searching key posts at Astrophorum.
  • Alexey Ropjanoi, who experimentally found out problem and eliminated it, proposing new shceme for shooting.
And I deeply thankful to my colleagues for Solid State physic department of Moscow Engineer Physics Institute.

Read more...

Friday, 7 December 2007

How to change MAC-address of Ethernet card

Sometimes changing MAC-address of a network card is needed. For example, when it used for authorisation by internet provider. This is relatively simple yet unobvious in a first time procedure, but here are some examples.



Temporary MAC-address change
Go to the terminal and type:
sudo ifconfig eth0 hw ether xx:xx:Xx:xx
and MAC-address change and will stay until reboot. If you wish to change
MAC-address permanently, you need to do this:


Permanent change of
MAC-address
In Debian, for example, go to  /etc/network/if-pre-up.d/ and create file from root named pre-up.
Let`s write to them strings like this:
#! /bin/sh
ifconfig eth0 hw ether 00:00:00:00
Change zeroes by needed
MAC-address. To make changes active immediately, restart of network subsystem is required:
/etc/init.d/networking restart
In first time, following diagnostic messages are expected to appear:
# /etc/init.d/networking restart
Setting up IP spoofing protection: rp_filter.
Reconfiguring network interfaces...SIOCDELRT: No such process
ifup: interface lo already configured
SIOCSIFHWADDR: Device or resource busy
run-parts: /etc/network/if-pre-up.d/pre-up exited with return code 1
done.
No problems, repeat command, and it will execute smoother:
notebeast:/home/beast# /etc/init.d/networking restart
Setting up IP spoofing protection: rp_filter.
Reconfiguring network interfaces...ifup: interface lo already configured
done.
Here we go, the MAC-address is changed permanently.


How to find out MAC-address of network card in Linux
It's very simple, just type:
sudo ifconfig
and you see something like this:
eth0 Link encap:Ethernet HWaddr 00:0A:E4:53:AA:2D
inet addr:10.26.49.77 Bcast:10.26.63.255 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:208554 errors:0 dropped:0 overruns:0 frame:0
TX packets:125071 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40664531 (38.7 MiB) TX bytes:45919980 (43.7 MiB)
Interrupt:21 Base address:0x4c00

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:18511 errors:0 dropped:0 overruns:0 frame:0
TX packets:18511 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:537155 (524.5 KiB) TX bytes:537155 (524.5 KiB)

One's MAC-address is emphased by red font colour.


Yet another tips to change MAC-address

For example, MAC-address in Gentoo can be changed in /etc/conf.d/net


mac_eth0="00:50:8D:63:41:DE"
config_eth0=( "192.168.100.37 netmask 255.255.252.0" )
routes_eth0=(
"default via 192.168.100.1"
)

Or edit /etc/network/interfaces adding one string:
pre-up ifconfig eth0 hw ether 00:00:00:00:00:00
Indeed, there are loads of variants, because it is Linux :-)

iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
hwaddress ether xxxxxxxxxxxx


Conclusion
This post can be useful to those who connected to Internet via provider authorising by MAC-address.

Read more...

Thursday, 6 December 2007

Yet another Linux to Windows printing tip

Problem: one have a printer shared for networks printing and connected to a windows machine. From the other side, there is Linux-powered machine with CUPS installed and we want to print on windows shared printer.
Solve: with CUPS webform, adding printer and specifying login guest for printing without a password in a windowish printer.

Let's consider a common situation: we have winXP computer with network address 192.168.1.1, it has network shared printer LaserJet 1200 visible by SAMBA with name HPLaserJ. From another windows machines all printed without problems, but from Linux machine with CUPS when you attempt to print something you getting error.

Connection failed with error NT_STATUS_ACCESS_DENIED

If you attempt to print on it via IPP, you get:
Unable to connect to SAMBA host, will retry in 60 seconds...foomatic-rip version $Revision$ running...

There is no password on shared printer in windows - it is empty.

Solve of this puzzle is ridiculously simple. Just add in CUPS webform new printer, choose "Windows printer via Samba", and in address field write:
smb://guest@192.168.1.1/HPLaserJ

And that's all! Printing without a problems!

It's incredible that in huge and pretty goofy CUPS documentation this useful example is missing.

In KDE applications you ought to choose local printing address 127.0.0.1:631.

Read more...

Saturday, 24 November 2007

How to configure webcam in Debian Linux

The friend of mine had been presented to me a webcam recently. On the box of Logitech QuickCam, there were logo of an alternative operation system, but in Debian configuration of a webcam is as easy as 1-2-3. Here are tips for configuration of a webcam.

Preparation
Some preparing words - if you didn`t compile your own kernel, this section can be omitted.
Webcam interface in kernel is almost like TVtuner - it is ordinary video device with /dev/video0 output. That`s why all articles about TVtuner configuration can help you as well. So, in kernel must be turned on:

  • v4l and all of it protocols (v4l monolithically, protocols - as modules)
  • i2c and it protocols (as well as during TVtuner configuration)
If it is enabled in kernel, you shouldn`t get any problems.


Installation
In the camera`s box was wrote: installation as simple as 1-2-3. So, I get pretty the same:

1. Installing software.
Instead of use of tonnes of proprietary garbage, let`s install from Debian repository:
sudo aptitude install gspca-source camorama
In the /usr/src directory, archive with driver source gspca-source.tar.bz2 will appear. Unpack it and change directory to /usr/src/modules/gspca and execute following:
make
Module must compile without errors. Next, do this:
sudo make install
This command will install your module in directory, were other kernel modules are placed. Optionally it can be executed:
sudo depmode -a
That`s itl, our goal is to load module of a webcam:
sudo modprobe gspca
Next step is to plug camera in USB and start the software.


2. Plugging the webcam
After you plug webcam into USB, it turns on green LED and in kernel logs should appear something like this:

usb 4-1: new full speed USB device using uhci_hcd and address 6
usb 4-1: configuration #1 chosen from 1 choice
/usr/src/modules/gspca/gspca_core.c: USB SPCA5XX camera found.(ZC3XX)
/usr/src/modules/gspca/gspca_core.c: [spca5xx_probe:3887] Camera type JPEG
/usr/src/modules/gspca/Vimicro/zc3xx.h: [zc3xx_config:515] Sensor ID:7
/usr/src/modules/gspca/Vimicro/zc3xx.h: [zc3xx_config:597] Find Sensor HV7131R(c)
/usr/src/modules/gspca/gspca_core.c: [spca5xx_getcapability:1165] maxw 640 maxh 480 minw 176 minh 144
usbcore: registered new interface driver gspca
/usr/src/modules/gspca/gspca_core.c: gspca driver 01.00.04 registered

It looks like the webcam had been recognised. Now the device file /dev/video0 must appear - this is actually our camera. After that, webcam's soft should be launched:
$ camorama
If all was done correctly, you should see video in a small window of Camorama. It can be something like this:


3. Start using the camera
Now you can use your cam in Wengophone for video conference with friends and colleagues. It is need to say that image processing from webcam consumes processor time very moderate, around 4-5% on my Pentium M 1.75 GHz laptop.

Besides video conferences in VoIP, one can turn fantasy on and find many interesting applications to webcam. You may use it as security camera or telemetric device: streamer program can grab pictures from it with a prescribed frequency.


Conclusion
Except that there were mentioned only RedmondOS, Logitech QuickCam Messanger webcam works great in Linux, and configured in same three steps minus tons of useless proprietaty garbage.

During the tweaking I used these great guidelines because of my custom-made kernel. Those who use distribution kernel, this guide may be helpful.

I am very grateful to my good old friend :-) for presented webcam - thanks a lot!
Read more...