warning: Creating default object from empty value in /data/web/1/000/027/003/273448/htdocs/ on line 33.

lyc - Linux Yamaha receiver control (over serial / RS232 interface)

Yamaha RX-V3800 and some older models like DSP-AX1 are great AV-Receiver, but unfortunately they have no control / web interface to manage it from outside. With a USB-Serial adapter connected to the reciver RS-232 interface, a computer or router and lyc you can control the reciver. In addition, a web interface can be created with wlyc to provide a web access to all network devices like PC, smartphone or tablet.

GitHub repository

Download binary - i386 compiled - Atheros AR9132 (TP-LINK TL-WR1043ND / TL-WDR4300 router)

HowTo compile and run
1. download lyc.c and Makefile
2. compile with: make
3. set up USB Serial adapter
4. run command:
./lyc input dvd
./lyc volume up

Run on OpenWrt router
1. download sources
2. comile with
make mips
4. copy lyc to OpenWRT router:
scp lyc root@OPENWRT_IP:/root/lyc
5. login to root@YOUR_OPENWRT_IP
6. download wlyc (OpenWrt wget can not access https, use http redirection)
wget -q -O /www/cgi-bin/wlyc
chmod 755 /www/cgi-bin/wlyc
7. Open im broser:
Example: http://ROUTER_IP/cgi-bin/wlyc?p1=input&p2=dvd

cros-compile script for OpenWRT - lyc source code

#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include "rxvx700.h" /* Yamaha RX-Vx700 protocol codes */

#define STX 0x02
#define ETX 0x03
#define DC1 0x11

int fd;

//Initialize serial port
int init_port()
    int portstatus = 0;

    struct termios options;
    // Get the current options for the port...
    tcgetattr(fd, &options);
    // Set the baud rates to 9600...'textB' un
    cfsetispeed(&options, B9600);
    cfsetospeed(&options, B9600);
    // Enable the receiver and setSTX local mode...
    options.c_cflag |= (CLOCAL | CREAD);

    options.c_cflag &= ~PARENB;
    options.c_cflag &= ~CSTOPB;
    options.c_cflag &= ~CSIZE;
    options.c_cflag |= CS8;
    //options.c_cflag |= SerialDataBitsInterp(8);           /* CS8 - Selects 8 data bits */
    options.c_cflag &= ~CRTSCTS;                            // disable hardware flow control
    options.c_iflag &= ~(IXON | IXOFF | IXANY);           // disable XON XOFF (for transmit and receive)
    //options.c_cflag |= CRTSCTS;                     /* enable hardware flow control */

    options.c_cc[VMIN] = 0;     //min carachters to be read
    options.c_cc[VTIME] = 0;    //Time to wait for data (tenths of seconds)

    // Set the new options for the port...
    //tcsetattr(fd, TCSANOW, &options);

    //Set the new options for the port...
    tcflush(fd, TCIFLUSH);
    if (tcsetattr(fd, TCSANOW, &options)==-1)
        perror("On tcsetattr:");
        portstatus = -1;
        portstatus = 1;

    return portstatus;

* send command to reciver
void send_cmd(const char *n) {
    int len = strlen(n);

    // create command
    char cmd[len + 2];
    cmd[len + 1]=ETX;

    // copy string to char array
    int i;
    for (i = 0; i < strlen(n); i++) {
        cmd[i + 1] = n[i];

    // debug
    for (i = 0; i < sizeof(cmd); i++) {
        printf("%c|", cmd[i]);

    write(fd, cmd, sizeof(cmd));

* send init command to reciver
void init_cmd() {
    char b[5];

    int n = write(fd, b, sizeof(b));

* open serial port
int open_port(void)
    int fd; /* File descriptor for the port */
    fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);

    if (fd == -1) {
        * Could not open the port.
        perror("open_port: Unable to open /dev/ttyUSB0 --- \n");
    } else {
        fcntl(fd, F_SETFL, 0);

    return (fd);

* decode command
int run_cmd(char *cmd1, char *cmd2) {
    int l = 0;

    // check parameter
    if(cmd1 != NULL) {
        l += strlen(cmd1);

    if(cmd2 != NULL) {
        l += strlen(cmd2);

    // put parameter together
    char c[l + 2];
    strcpy(c, cmd1);
    if(cmd2 != NULL) {
        strcat(c, " ");
        strcat(c, cmd2);

    int i;
    int size = (int)(sizeof(cmd) / sizeof(*cmd));
    for(i = 0; i < size; i++) {
        // search command
        if(strcmp(c, cmd[i][0]) == 0) {
            // todo calculate volume
            // int i = (int)strtol(cmd[i][1], (char **)NULL, 10);

            char code[strlen(cmd[i][1]) + 1];
            strcpy(code, cmd[i][1]);

            char *pch;
            pch = strtok(code, " ");
            while (pch != NULL) {

                pch = strtok(NULL, " ");

            return 0;

    return 1;

* main
int main(int argc, char **argv) {
    if(argc == 1) {
        return 1;
    fd = open_port();

    if(fd == -1) {
        printf("Error opening serial port\n");
    } else {
        if(init_port() == -1) {  
            printf("Error initializing serial port\n");

            return 0;


        // todo: recive response from reciver
        if (n < 0) {
            fputs("write() of X bytes failed!\n", stderr);
        } else {
            printf("Successfully wrote 8 bytes\n");

            char buffer[200];
            int n = read(fd, buffer, sizeof(buffer));
            if (n < 0) {
                fputs("read failed!\n", stderr);
            } else {
                printf("Successfully read from serial port -- %s\n", buffer);

        if(run_cmd(argv[1], argv[2]) == 1) {
            printf("Command not found\n");


    return 0;
} - Yamaha RS232 codes

// todo: add Zone2 and Zone3
const char* cmd[][2] = {
    {"power on", "07E7E"},
    {"power off", "07E7F"},

    {"input cd", "07A15"},
    {"input dvd", "07AC1"},
    {"input bd", "07AC8"},
    {"input netusb", "0F7F013FC0"},
    {"input usb",   "0F7F013FC0 0F7F0138C7"},
    {"input net",   "0F7F013FC0 0F7F0137C8"},
    {"input pc",    "0F7F013FC0 0F7F0136C9"}, 

    {"volume up", "07A1A"},
    {"volume down", "07A1B"}, 
    {"volume -30", "2308B"},
    {"volume -35", "23081"},
    {"volume -40", "23077"},
    {"volume -45", "2306D"},
    {"volume -50", "23063"},
    {"volume -55", "23059"},
    {"volume -60", "2304F"},
    {"volume -65", "23045"},
    {"volume -70", "2303B"},
    {"volume -75", "23031"},
    {"volume -80", "23027"},

    {"mute on", "07EA2"},
    {"mute off", "07EA3"},

    {"sleep off", "07EB3"},
    {"sleep 120", "07EB4"},
    {"sleep 90", "07EB5"},
    {"sleep 60", "07EB6"},
    {"sleep 30", "07EB7"},

    {"dsp 7ch", "07EFF"},
    {"dsp 2ch", "07EC0"},
    {"dsp normal", "07EFD"},
    {"dsp straight", "07EE0"},
    {"dsp general", "07EFC"},

    {"memory 1", "07E35"},
    {"memory 2", "07E36"},
    {"memory 3", "07E37"},
    {"memory 4", "07E38"},
    {"memory 5", "07E39"},
    {"memory 6", "07E3A"},

    {"osd menu", "0F7F012FD0"},
    {"osd enter", "0F7F0131CE"},
    {"osd display", "0F7F0135CA"},
    {"osd up", "0F7F012ED1"},
    {"osd down", "0F7F0134CB"},
    {"osd left", "0F7F0132CD"},
    {"osd right", "0F7F0130CF"},

    {"enhancer on", "07ED8"},
    {"enhancer off", "07ED9"},

    {"stop", "0F7F013DC2"},
    {"play", "0F7F013EC1"},
    {"next", "0F7F013CC3"},
    {"prev", "0F7F013BC4"},

}; - Makefile


	gcc $(FLAGS) $(INCLUDEDIR) lyc.c -o lyc

	arm-linux-gnueabihf-gcc lyc.c -o lyc

	$(STAGING_DIR)/mips-openwrt-linux-uclibc-gcc lyc.c -o lyc
	rm -f *~ *.o *.cgi lyc


Ubuntu: temperature monitoring with TEMPer USB sensor / thermometer

Bus 005 Device 012: ID 0c45:7401 Microdia

download already compiled version
sudo wget -q -O /usr/local/bin/pcsensor
sudo chmod a+x /usr/local/bin/pcsensor
sudo watch /usr/local/bin/pcsensor

compile self
# install libs
sudo apt-get install -y libusb-dev libusb-1.0-0 make #libhid-dev

# get source
#wget -O /tmp/pcsensor-0.0.1.tgz
#tar xzf /tmp/pcsensor-0.0.1.tgz -C /tmp
#cd /tmp/pcsensor-0.0.1
mkdir /tmp/pcsensor

Linux Kernel benchmark results

Results extract
real 0m22.993s
user 0m20.720s
sys 0m9.100s

real 0m11.023s
user 0m10.773s
sys 0m1.548s

Quad-Core AMD Opteron(tm) Processor 2347 HE (4x)
real 0m31.517s
user 0m29.330s
sys 0m5.500s

Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz (12x)
real 0m11.230s
user 0m11.185s
sys 0m0.584s

2400 (amd64)
real 0m36.775s
user 0m29.718s
sys 0m3.376s

2400 (dom0)
real 0m39.682s
user 0m32.146s
sys 0m6.668s

2400 (domU)
real 0m39.397s
user 0m32.314s
sys 0m6.708s

2400 amd64 1core
real 15m40.146s
user 14m41.987s
sys 1m34.486s

AX88772A Fast Ethernet USB Adapter

Set fixed ethernet device
cat <> /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ATTR{address}=="00:11:22:33:44:55",KERNEL=="eth*", NAME="eth1"

Configure IP
cat <> /etc/network/interfaces
auto eth1
iface eth1 inet dhcp

Bus 002 Device 003: ID 0b95:772a ASIX Electronics Corp. AX88772A Fast Ethernet

lsmod | grep asix
asix 27650 0
usbnet 31879 1 asix


Autostart script from USB device with Udev

Stage 1: Create Udev rule
sudo wget -O /etc/udev/rules.d/70-persistent-usb_autorun.rules

SUBSYSTEM=="block", KERNEL=="sd*1", ACTION=="add", RUN="/usr/sbin/ %E{ID_FS_LABEL} %E{ID_FS_UUID}"

Stage 2: Create autorun wrapper
sudo wget -O /usr/sbin/
sudo chmod a+x /usr/sbin/


autorun() {
    if [ -z ${1} ]; then

    sleep 10

    if [ -f ${FILE} ]; then
        /bin/bash ${FILE}

autorun $@ &

Stage 3: Create script on your USB device (example)
wget -O ./
chmod a+x ./


USER=$(who | cut -d" " -f1 | head -1)

LOG="${0%/*}/backup.$(date -I).log"
CMD="/bin/bash ${0%/*}/ | tee -a ${LOG}"

if [ -f /home/"${USER}"/.Xauthority ]; then
    # try to open xterm
    export XAUTHORITY=/home/${USER}/.Xauthority
    export DISPLAY=:0.0

    notify-send -i drive-harddisk-usb "Backup" "USB backup started"

    xterm -e ${CMD}

    notify-send -i dialog-ok "Backup" "USB backup completed"
    # no X11, run on console

# send log by email if sendmail available
if [ -x /usr/sbin/sendmail -a -n "${MAILTO}" ]; then
    # change user for nullmailer

    echo "Subject: Backup Log from ${HOSTNAME}" | cat - ${LOG} | sendmail ${MAILTO} 

How Linux is Built

smartmontools (smartctl)

wget -q --no-check-certificate -O - | bash -


# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
sudo $0

apt-get install -y smartmontools --no-install-recommends

Enable SMART on device
sudo smartctl -s on /dev/sdb

Show device SMART Health status
sudo smartctl -H /dev/sda

Show device selftest log
smartctl -l selftest /dev/sdb

Get info from usb data
sudo smartctl -d sat -a /dev/sdb

smartctl -t short /dev/sdb
smartctl -t offline /dev/sdb

Calculate total writen GB from a SSD
echo "Total GB written: $(echo "scale=3; $(sudo /usr/sbin/smartctl -A /dev/sda | grep "Total_LBAs_Written" | awk '{print $10}') * 512 / $((1024*1024*1024))" | bc)"


Check / Update DDNS

wget -O /etc/cron.d/checkddns

0 * * * *     /sbin/

wget -O /sbin/


if [ ! -z $1 ]; then
	echo "Hostname missing"
	echo "Usage: $0"
	exit 1

IP_DNS=$(ping -c 1 | head -1 | cut -d"(" -f2 | cut -d")" -f1)
IP_LOCAL=$(ifconfig | grep inet | tail -2 | head -1 | cut -d":" -f2 | cut -d" " -f1)

ping -c 1 ${URL} > /dev/null
if [ $? -gt 0 -o "${IP_DNS}" != "${IP_LOCAL}" ]; then
	echo "Update Dynamic DNS..." 

chmod u+x /sbin/
/etc/init.d/fcron restart

Toshiba Tegra AC100



install nvflash (broken, download and install manually)
wget -O /tmp/nvflash_20110628-2_all.deb
sudo dpkg -i /tmp/nvflash_20110628-2_all.deb

get bootrom
# wget -O /tmp/ac100.bootimg
# wget -O /tmp/ac100.bootimg
wget -O /tmp/ac100.bootimg

flash bootrom
# Connect the USB cable between your AC100 and the host PC
# Press CTRL and ESC keys and power on your AC100
sudo nvflash --bl /usr/lib/nvflash/fastboot.bin --download 6 /tmp/ac100.bootimg
# poweroff
# poweron

download image
sudo mount /dev/sdb1 /mnt

# wget -P /mnt/
# wget -P /mnt/
wget -O /tmp/trusty-preinstalled-desktop-armhf+ac100.tar.gz

sudo umount /mnt

# OPTIONAL configuration
wget -O - | sudo bash -


# update packages
sudo apt-get update
sudo apt-get -y dist-upgrade

# configure german keyboard
sudo sed -i 's|XKBLAYOUT="us"|XKBLAYOUT="de"|g' /etc/default/keyboard

# disable unnececery services 
sudo update-rc.d -f avahi-daemon remove
sudo update-rc.d -f bluetooth remove

sudo mkdir /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/orca-autostart.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/vino-server.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/bluetooth-applet.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/bluetooth-applet-unity.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/jockey-gtk.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/deja-dup-monitor.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/onboard-autostart.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/user-dirs-update-gtk.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/ubuntuone-launch.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/update-notifier.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/gnome-user-share.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/telepathy-indicator.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/gwibber.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/gdu-notification-daemon.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/zeitgeist-datahub.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/pulseaudio-kde.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/print-applet.desktop /etc/xdg/autostart/disabled
sudo mv /etc/xdg/autostart/nautilus-autostart.desktop /etc/xdg/autostart/disabled

# remove unnecessary apps
sudo apt-get remove -y gnome-screensaver
sudo apt-get remove -y gnome-orca onboard
sudo apt-get remove -y brasero
sudo apt-get remove -y zeitgeist
sudo apt-get remove -y rhythmbox
sudo apt-get remove -y unity
sudo apt-get remove -y totem

# install extra apps
sudo apt-get install -y language-pack-de language-pack-gnome-de
sudo apt-get install -y thunderbird-locale-de thunderbird-locale-en hunspell-de-de hunspell-en-us
sudo apt-get install -y openvpn network-manager-openvpn
sudo apt-get install -y language-pack-de-base
sudo apt-get install -y sshfs vlc 

# ubuntu 12.04 (gnome)
# configure repository
cat < /etc/apt/sources.list
deb precise main restricted universe multiverse
deb precise-security main restricted universe multiverse
deb precise-updates main restricted universe multiverse
#deb precise-proposed main restricted universe multiverse

# install gnome classic
wget -O - | bash -

gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t boolean -s /apps/gnome-screensaver/idle_activation_enabled false
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t boolean -s /apps/gnome-power-manager/lock_on_blank_screen false
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t -s /apps/gnome-power-manager/lock_use_screensaver_settings false
#gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'
#gsettings set org.gnome.power-manager lock-use-screensaver 'false'

# configure nautilus (broken ?)
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t string -s /apps/nautilus/preferences/default_folder_viewer 'list_view'
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t string -s /apps/nautilus/list_view/default_zoom_level smallest
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults/ -t string -s /apps/nautilus/preferences/show_directory_item_counts never

# ubuntu 12.10 (lxdm)
# install nvidia driver
if [ $(lsb_release -rs | tr -d ".") -ge 1210 ]; then
    sudo dpkg -i nvidia-tegra_16.2.0-0ubuntu3_armhf.deb nvidia-tegra-ventana-codecs_16.0.0-0ubuntu1_armhf.deb

# clean up
sudo apt-get -y autoremove
sudo apt-get clean

echo "*** ac100 postinstall done, reboot in 30 sec ***"
sleep 30

sudo reboot

# todo
# autologin
# remove screen lock
# nvidia tegra graphic
#dpkg -i Downloads/nvidia-tegra_12~beta1-0ubuntu1_armel.deb

Ubuntu images for AC100

Links - Ubuntu 12.10 / 12.04 Nvidia graphic driver for Toshiba AC100 - NvFlash

Accelated Video
sudo dpkg -i linux-image-3.1.10-6-ac100_3.1.10-6.9_armhf.deb nvidia-tegra_16.1.0-0ubuntu3~fly2_armhf.deb
nvgstplayer -i "file://$1" --svs="nvxvimagesink" --sas="nv_omx_audiosink"

Java Linux ARM v6/v7 VFP

# axis

# kali

# old
sudo echo "deb unreleased main non-free" > /etc/apt/sources.list.d/
sudo apt-key adv --keyserver --recv-keys AC2A5FFE00823EC2
sudo apt-get update
sudo apt-get -y --force-yes install xserver-xorg-video-tegra

wget -O /tmp/nvidia-tegra_12-0ubuntu1~alpha1monson6_armel.deb
sudo dpkg -i /tmp/nvidia-tegra_12-0ubuntu1~alpha1monson6_armel.deb

Syndicate content