2016-11-23

HOWTO: some experience with USB IrDA adapter (MA-620) on Debian Linux

Well, let's test it on Debian GNU/Linux (and it should work on Ubuntu and other derivatives too).
$ lsusb
...
Bus 002 Device 003: ID 0df7:0620 Mobile Action Technology, Inc. MA-620 Infrared Adapter
...
# lsusb -v -d 0df7:0620

Bus 002 Device 003: ID 0df7:0620 Mobile Action Technology, Inc. MA-620 Infrared Adapter
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0df7 Mobile Action Technology, Inc.
  idProduct          0x0620 MA-620 Infrared Adapter
  bcdDevice            0.10
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
...
$ dmesg | grep pl2303
...
[ 3554.878546] usb 6-1: pl2303 converter now attached to ttyUSB0
...
$ ls /dev/ttyUSB*
/dev/ttyUSB0
It turns out to be a variation of MA-600 serial IR adapter with integrated PL-2303 USB-to-serial bridge.

On the other side of this optical connection we'll try a Sony Ericsson T630 phone.

Note: I didn't manage it to work reliably with baudrates greater than 9600 bps (perhaps bad adapter, not phone); if you have a good adapter specimen, you can probably have speeds up to 115200 bps.

Anyway, to work with IrDA you need to install the following package (in my Debian "testing" environment, it has "0.9.18-14" version, but your distribution probably has it "0.9.18" too):
# apt-get install irda-utils
Perhaps, you'll see some configuration dialogs during installation. Anyway, you can return back to guided configuration at any time:
# dpkg-reconfigure irda-utils
And it's sometimes better to edit /etc/default/irda-utils directly (e. g., via "sudoedit /etc/default/irda-utils").
Following is a sample config for reference.
# Set your startup settings for irattach, the IrDA-daemon, here.

# Set this to 'false' if you do not need to start irattach. Otherwise set it
# to 'true'.
ENABLE="true"

# Set discovery mode which usually is a good idea for finding other devices.
# If set 'true' or 'false' irattach and sysctl are used to enable and disable
# discovery mode. By default discover mode is disabled.
DISCOVERY="true"

# Set IRDA device to access (e.g. /dev/ttyS1 or irda0).
# In case of irda0, the proper module for FIR-mode has to be set in
# /etc/modprobe.d/irda-utils.conf
DEVICE="/dev/ttyUSB0"

# Set dongle type, e.g. none, tekram, esi, actisys, actisys+, ep7211, girbil,
# litelink, airport, old_belkin, mcp2120, act200l, ma600). You do not need
# a dongle for FIR mode.
DONGLE="ma600"

# Set the serial device to quiet with setserial. This is only useful on some
# machines in FIR-mode, so most people should leave it blank. See 
# README.Debian for more information.
SETSERIAL=""

# Some laptops (Toshiba Satellites and others with SMCS LPC47N227) require
# running smcinit to initialize the irda device prior to use.
# If you device is one of them, set this option to "yes"
USE_SMCINIT="no"

# Set the max baud rate for IrDA device
# Values: 2400, 3600, 9600, 14400, 19200, 28800, 38400, 57600, 115200
MAX_BAUD_RATE="9600"
And you can start/stop/restart that service as usual:
# /etc/init.d/irda-utils start
# /etc/init.d/irda-utils stop
# /etc/init.d/irda-utils restart
But I don't really like it getting started on every boot, and prefer the "manual" way instead (at first, by setting ENABLE="false" in the config and stopping the service, if running).
# irattach /dev/ttyUSB0 -d ma600 -s

$ /sbin/sysctl net.irda.max_baud_rate
net.irda.max_baud_rate = 16000000

# sysctl net.irda.max_baud_rate=9600
net.irda.max_baud_rate = 9600

$ /sbin/ifconfig irda0
irda0: flags=193<UP,RUNNING,NOARP>  mtu 2048
        irda 12:34:56:ff  txqueuelen 8  (IrLAP)
        RX packets 1  bytes 28 (28.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 109 (109.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

And when you're tired of it, just kill irattach (and then unplug the adapter):
# killall irattach
If you need IR serial port emulation, you also need to load an appropriate kernel module:
# modprobe ircomm_tty

$ lsmod | grep ircomm_tty
ircomm_tty ...

$ ls /dev/ircomm*
/dev/ircomm0
/dev/ircomm1
...
/dev/ircomm31
Here is a sample snippet from ~/.gammurc (a config file used by Wammu / Gammu mobile phone manager):

[gammu2]
port = /dev/ircomm0
connection = at
name = IrDA
model = 
...

References & other useful links:
  1. Debian Package Tracker - irda-utils
  2. man irattach
  3. The Linux-IrDA Project (on SourceForge) / Linux-IrDA Project (homepage on SourceForge)
  4. Linux-IrDA quick tutorial (at HP Labs) [web-archived on 2016-01-21] (a dead link / an older dead link)
    1. MA620 notes [web-archived on 2016-01-22] (a dead link / an older dead link)
  5. Linux Infrared HOWTO - TuxMobil / The Linux Documentation Project mirror
  6. Debian Package Tracker - gammu
  7. Debian Package Tracker - wammu
  8. IrdaHowto - Ubuntu Community Help Wiki (outdated)

TODO / see also / other interesting things:
---
Last updated: 2016-11-24

2016-06-09

HOWTO: fix mic settings on Acer Aspire 3810T notebook in Linux

Once upon a time... You try a Linux Skype version (e. g., 4.3.0.37-1 for Debian) on Acer Aspire 3810T notebook and no sound is heard from the internal microphone.

The microphone is not muted in AlsaMixer (alsamixer); in PulseAudio Volume Control (pavucontrol) mic looks OK too.

Let's record some mic sound using Audacity audio editor... Here is a screenshot:
As you can see, the right channel ("R") is simply inverted left channel ("L"); let's call that "R=-L".

Let's look at the system environment details...
$ uname -a
Linux Notebook1 4.5.0-1-amd64 #1 SMP Debian 4.5.1-1 (2016-04-14) x86_64 GNU/Linux

$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k4.5.0-1-amd64.

$ dmesg | grep Acer
[    0.000000] DMI: Acer Aspire 3810T/Aspire 3810T, BIOS V1.28 08/10/2010
...

$ dmesg | grep snd_hda_codec_realtek
[    3.796475] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC269: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    3.796496] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    3.796510] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x15/0x0/0x0/0x0/0x0)
[    3.796522] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[    3.796531] snd_hda_codec_realtek hdaudioC0D0:    dig-out=0x1e/0x0
[    3.796540] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[    3.796550] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x18
[    3.796559] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12

$ dmesg | grep HDA
[    3.854039] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[    3.855277] input: HDA Intel Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[    3.855365] input: HDA Intel Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
[    3.855451] input: HDA Intel HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16

$ cat /proc/asound/pcm
00-00: ALC269 Analog : ALC269 Analog : playback 1 : capture 1
00-01: ALC269 Digital : ALC269 Digital : playback 1
00-03: HDMI 0 : HDMI 0 : playback 1

$ cat /sys/module/snd_hda_intel/parameters/model
(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
Nothing interesting, except the Realtek ALC269 audio codec.

Thus, it's time to look at the microphone itself.
Terminal markings (DATA, VDD, CLK, GND) suggest it's a digital microphone (not analog one), and it looks like a mono (1-channel) one.

Fortunately, there is a way to fix the problem: you should create a modprobe configuration file with appropriate settings for Intel HDA driver kernel module.

If you're interested, you can get some info about some kernel modules:
$ /sbin/modinfo snd-hda-intel
...
$ /sbin/modinfo snd-hda-codec-realtek
...
But let's get back to the configuration.
Create, e. g., a /etc/modprobe.d/sound.conf file and put an appropriate configuration string (i. e., options snd-hda-intel model=MODEL, where MODEL is a specific model string) into it:
$ sudoedit /etc/modprobe.d/sound.conf
...
Let's try some model names that look usable.
  1. "laptop-amic".
    Some minor changes in dmesg output:
    $ dmesg | grep snd_hda_codec_realtek
    ...
    [    3.803435] snd_hda_codec_realtek hdaudioC0D0:    inputs:
    [    3.812954] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x18
    [    3.817411] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x19
    [    3.817414] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
    
    And major effects on mic sound output:
    Yes, funny enough, it's a stereo low-level noise, and there's no intelligible sound (!); and that's not strange: "amic" stands for "analog microphone", so it's just a useless option for digital ones.
  2. "laptop-dmic".
    R=-L (no significant changes).
  3. "alc269-dmic".
    R=L.
  4. "alc271-dmic".
    R=-L (no significant changes).
  5. "inv-dmic".
    Some audio signal in the left channel, and no signal (zero level) in the right one (R=0).
Conclusion: "inv-dmic" represents the real configuration (if you want pseudo-stereo, you can also try "alc269-dmic"); so here is my suggested config:
$ cat /etc/modprobe.d/sound.conf
options snd-hda-intel model=inv-dmic

$ cat /sys/module/snd_hda_intel/parameters/model
inv-dmic,(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
External links:
      1. https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt
      2. https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt
      3. https://www.kernel.org/doc/Documentation/sound/alsa/alsa-parameters.txt
    1. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_realtek.c (kernel/git/torvalds/linux.git - Linux kernel source tree)
  1. ALSA - Debian Wiki
  2. HdaIntelSoundHowto - Community Help Wiki (Ubuntu)

2016-05-20

Software: gpm, a mouse service for Linux console

There's a nice piece of software called gpm (general purpose mouse).
It's a mouse server for Linux console. (BTW, touchpads are supported too).

In Debian (and its derivatives like Ubuntu), it's very easy to start using it by simple installation from package repositories:
# apt-get install gpm
And you should see a rectangular mouse pointer soon ;)

In case it gets stuck, you can try restarting the gpm service this way:
# service gpm restart
or, a more generic command if you don't use Debian:
# /etc/init.d/gpm restart
See also: HOWTO: reload mouse driver in Linux

External links:
---
Last updated: 2016-07-04

2016-04-29

HOWTO: force filesystem check on reboot in a Linux system

Usually, only a superficial file system check is performed automatically on boot up, and it's sufficient; but sometimes it could be handy to force a full file system check (i. e., to run the Linux fsck utility) to ensure the FS is really OK.
  1. Classic init (SysVinit): just reboot the system with a special option:
    # shutdown -rF now
  2. systemd init: much more interesting: at the boot time, you need to append a special kernel command line parameter (e. g., you can specify it at the GRUB command line):
    linux /boot/vmlinuz root=UUID=... ro fsck.mode=force

P. S. It should then check all the filesystems enabled for checking in /etc/fstab.

References:
  1. man shutdown
  2. man systemd-fsck
  3. man fstab
  4. man fsck

2016-01-27

HOWTO: play MIDI files with VLC in Debian

It's very easy! And should also work for Ubuntu (and other Debian derivatives).
  1. First of all, make sure you have already installed the VLC media player:
    # apt-get install vlc
  2. Install the FluidSynth plugin:
    # apt-get install vlc-plugin-fluidsynth
  3. Enjoy!
    You can open your file either with the VLC GUI, or from the CLI, e. g.:
    $ vlc ~/Music/MyFavoriteSong.midi

2015-12-28

HOWTO: preventing aptitude from breaking the APT package setup

Initial conditions:
  • usually, you use apt-get (from the apt package) for Debian package maintenance (installing, removing, upgrading etc.);
  • sometimes you launch aptitude (aptitude package) to do some work;
  • after doing some work with apt-get, you notice that aptitude hasn't caught up with the current package state (i. e., it wants to install / remove some package(s) just from the start).
Solution: hide (or delete) the outdated package states file from aptitude (note: it'll overwrite an old backup, "/var/lib/aptitude/pkgstates.old", if present):
$ cd /var/lib/aptitude
# mv pkgstates pkgstates.old
P. S. This should also work for Debian derivatives (e. g. Ubuntu).

2015-12-04

Hardware accident: Chinese LED lantern turned into a firework

Device brand / model: Yajia YJ-6812
Description: a Chinese lantern with 32 LEDs (quite bright really; 2 levels of brightness); rechargeable (no information on battery currently); without any external power adapters (plugged directly into AC socket by a simple 2-wire cable). Bought on a local Ukrainian (Vinnytsia city) market. The design somewhat reminds of a kind of grater.

2015-11-30

Software: MediaInfo

Currently, MediaInfo is probably the best free & open-source utility for extracting technical info (metadata) from multimedia files (most frequently, containers with audio and video streams).
It's quite portable (runs on various Linux distributions, MS Windows, Apple Mac OS X, FreeBSD etc.; released regularly in source and compiled binary forms) and comes with CLI and GUI interfaces.

External links:

2015-10-31

HOWTO: force filesystem check on reboot in MS Windows (NT family)

These tricks may be well-known, but still handy for busy volumes (e. g., the system one):
  1. Open a command prompt (cmd) with administrator privileges (either via "Start → Run..." menu, "<WinKey> + <R>" hotkey, or other methods you like).
  2. Two options.
    1. Marking volume "dirty":
      > fsutil dirty set C:
      Volume - C: is now marked dirty
      
    2. A milder option, just scheduling the volume to be checked on startup:
      > chkntfs /C C:
      
      
  3. Reboot safely.
  4. Watch the CHKDSK operation progress...
  5. DONE!
    (You can check the CHKDSK logs later in the "Event Viewer" (eventvwr.msc or simply eventvwr for short)).
References:
---
Last updated: 2016-05-20

Hints: D-Link ADSL router: time to change the power adapter

Sample device: D-Link DSL-2640* (quite old combined ADSL modem / Ethernet switch / Wi-Fi router); should probably work for some other Linux-based routers with Broadcom chips.

Some trouble signs include: red power lights, not booting into the normal working mode (or booting into the recovery one) after power-on; slowing down of the operation, decrease of the performance & significant packet dropping rate; unexpected restarts etc.

Reliable internal software (firmware) symptoms — specific log strings get triggered, e. g.:
  • accessed via the web-based interface:
    System Log
    Date/TimeFacilitySeverityMessage
    ....
    Jan 1 00:01:23userwarn
    kernel: - Power glitch detected. Duration: 5 us
  • and via Telnet / SSH:
    ...
    > sh
    ...
    # dmesg
    ...
     - Power glitch detected. Duration: 6 us
    ...
    
    • Note: reportedly, some users also observe another diagnostic log message:
       - Power failure detected. ADSL Link down.
What to do:
  1. check the power cabling (and fix it, if needed);
  2. check the electrolytic capacitors:
    1. inside the power adapter,
    2. and in the router itself,
    3. and replace (resolder) the blown-up ones with new ones (paying attention to the nominal values, indeed);
  3. buy a new power adapter, if needed.
Safety notes:
  • BEWARE of electric shock.
  • Disconnect the AC power before opening the cases.
  • Some technical experience needed.
---
Last updated: 2015-11-30