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...

Thursday, 27 December 2007

Bibliography in LaTex: JabRef

Problem: bibliographical list of cites in LaTeX being grown and became on the thither side of fifty sources. Sorting and storing of bibliographical list in scientific papers is evident.
Solve: there is cross platform system for bibliography base - JabRef.

During creation of vast scientific works, problems with bibliography in LaTeX frequently arises. In the base level of LaTeX study, users applies direct links to literature in the TEX-file:

\addcontentsline{toc}{chapter}{References}
\begin{thebibliography}{99}

\bibitem{catheydowskinewparadigm} W.T. Cathey and E.R. Dowski, ``New paradigm for imaging systems'', Appl. Opt. 41, pp. 6080-6092, 2002.
This means literally "add section References at the end of table of contents, and enumerate links (bibitem) as they follows in bibliography list". And that is where shoe pinches for LaTeX-beginners - in the text links will have been enumerated as they are in list of references but not in the order of citing.

Besides that, where will be a big problems when you want to include part of bibliography items in another document. Which of them are useful, and in what order? To prevent such kind of problems, BiBTeX was invented.


Bibliography databases
This is a simple text file, where all you bibliography sources are listed. Such file can be used by LaTeX to produce bbl-file with only that literature sources, which were cited in document.
Every time you compiling you LaTeX document, BiBTeX searches citations in base and substitutes them into bbl-file. Obtained bbl-file is used as "thebibliography" list - but it created automatically.

Hence, you don't need to fight with bibliography in LaTeX - just add literature to you BiBTeX base using fancy GUI program. Created bibliography base can be used with many document, and benefits are:
  1. if there are any errors in literature item, it can be corrected in the BibTeX base only - and all documents, which are using this base, will be corrected automatically after next recompilation;
  2. links appears in desirable order and numbered automatically;
  3. you can search literature in base to find out bibtex key to substitute in \cite{};
  4. one BiBTeX base can be used in loads of documents;
  5. import \ export in different formats is possible.
Thus, you ought to make an effort to use BiBTeX - using you bib-base, it is possible to simply type \cite{source} and don't pay attention on which order cited literature appears in document. Simple and easy.


How it works
To start working with BiBTeX, it is necessary to install any program to work with BiBTeX, create new bib-base and full it with literature sources which you have. If you wrote early at the end of document:
\addcontentsline{toc}{chapter}{Reference}
\begin{thebibliography}{99}
hence, now you must point to bib-base like that (don't write .bib extension!):
\bibliography{path/to/bibliography/file}
e.g.,
\bibliography{biblio/my}
and, apart from other, choose bibliography style which you want to use - often unsorted list is used (i.e., in order of mentioning in text):
\bibliographystyle{unsrt}
This string must be pasted in header of LaTeX document, after \usepackage but before \begin{document}.

Here we exploiting possibilities of our OS, which alleviates our life: use symlinks. For example, we have two documents in different directories, but they using the same bib-base. How can it be used in either documents? Easily:just make symbolic link to directory with bib-base file and copy this symlink in desirable directories. This can be done in any UNIX systems.

So, if we have bibliography base file my.bib placed in ~/docs/matlab/docus/topics/biblio/ we need to point in LaTeX document to it \bibliography{biblio/my} and make symlink on directory:
ln -s ~/docs/matlab/docus/topics/biblio/ biblio
and copy symlink in desirable directories. That's all, you LaTeX documents will work with bib-base.


Installation
For described miracles to be working, installation of bibtex-viewer program is required. Let's use crossplatform software JabRef, Java-written and GPL-licensed.

Hence, we need to download from Internet  j2re*.deb (for example, jpre1.4_1.4.2.03-1_i386.deb), jabref*_all.deb (I have jabref_2.0.1-1_all.deb) and take first DVD-disk with Debian.

Firstly, installing  java-common :
#apt-get install java-common
Then installing Java-machine (correct file name if you have another version of Java):
#dpkg -i jpre1.4_1.4.2.03-1_i386.deb
Several questions may be asked during installation process, such as licence agreement. Then install JabRef - as separate package, if it isn't in distribution:
#dpkg -i jabref_2.0.1-1_all.deb
That's it: now add  JabRef to menu of you favourite window manager and run:
jabref
Don't forget to correct your LaTeX documents and point LaTeX to use BibTeX base:
\bibliography{path/to/bib-file/base}
and work as usual - citing literature and don't boring, BibTeX will do this job instead of us. At the end of document references will be typesetted by all rules.


A few advises
Fistly, don't forget to backup you bib-base. It can be exported in different formats or simply be copied in different disk

Second, many journals as SpringerLink or Elsavier brings Citations for published works. Don't miss them and collect this files - they are usually in RIS or BIB-formats. Download them and the import to JabRef base, give them bibkey names and you get proper citing of desirable article.

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...