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.

The internals of my USB IR adapter: a PCB
("EM78P153SN" is some kind of a MCU).

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: 2017-03-29

No comments:

Post a Comment