Guide to iRTrans Server on rPI3

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

Post Reply
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Guide to iRTrans Server on rPI3

Post by emme »

Hi,

Based on my poor experience in coding in a linux enviroment, I'm quite pround to have been able to install a full function iRTrans server on my rPI3 running Domoticz.
Most of the information here came form a deep reading of the iRTrans nonsupport forum (in deutch! :evil: ... while I'm italian and I don't nothing about german language)
I would like to share my personal guide in order to help other users.

Here's what I did:

SCENARIO
  • Raspberry PI3,
  • Domoticz SD Card image
NEEDS
Use iRTans LAN with NO DB Support to control devices (Sky, air cond/heat split, TV and any other iR Device)
The choice of iRTrans is because... I have this available.... :P

IRSERVER SETUP
In case of device with no buit-in iRDB support, iRTrans can be used via iRServer software.

iRServer, in a linux enviroment, is available in 2 option:
Compiled for x86 and x64 Intel enviroments (rPI is ARM) or Source Code witch need to be recompiled (this is my case)

first I created a temp directory named irserver and another folder named arm under /home/pi and then I downloaded and unpack the server source code

Code: Select all

mkdir /home/pi/irserver
mkdir /home/pi/irserver/arm
cd /home/pi/irserver
wget http://www.irtrans.de/download/Server/Linux/irserver-src.tar.gz
tar -xvf irserver-src.tar.gz 
At this point we should just start compiling the code, BUT, we first need to change few lines in makefile or we will get errors that will stop compiling

Code: Select all

nano makefile
the file will need to looks like this (you can cut/paste and delete the other lines)

Code: Select all

SHELL = /bin/sh

CC = gcc

CFLAGS = 
CPPFLAGS = -DLINUX -DMEDIACENTER
LDFLAGS =
LIBS =
#ODIR = x86
#ODIR64 = x64
ODIRARM = arm

_OBJS = fileio.o linuxserio.o lowlevel.o server.o errormessage.o flashrom.o webserver.o xap.o lanio.o ascii.o mce.o xbmc.o
#OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
#OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))


#irserver: $(OBJS) $(ODIR)/ccf.o 
#	$(CC) $(CFLAGS) $(OBJS) $(ODIR)/ccf.o -m32 -o irserver $(LDFLAGS)

#irserver_noccf: $(OBJS) $(ODIR)/noccf.o
#	$(CC) $(CFLAGS) $(OBJS) $(ODIR)/noccf.o -m32 -o irserver $(LDFLAGS)

#irserver64: $(OBJS64) $(ODIR64)/ccf.o 
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(ODIR64)/ccf.o -m64 -o irserver64 $(LDFLAGS)

#irserver64_noccf: $(OBJS64) $(ODIR64)/noccf.o
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(ODIR64)/noccf.o -m64 -o irserver64 $(LDFLAGS)

#irserver_arm: $(OBJSARM) $(ODIRARM)/ccf.o 
#	$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/ccf.o -o irserver $(LDFLAGS)

irserver_arm_noccf: $(OBJSARM) $(ODIRARM)/noccf.o 
$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/noccf.o -o irserver $(LDFLAGS)

#all: irserver irserver64

#arm: irserver_arm

arm_noccf: irserver_arm_noccf

clean:
#	-rm $(OBJS) x86/noccf.o
#	-rm $(OBJS64) x64/noccf.o
-rm $(OBJSARM) arm/noccf.o


#$(ODIR)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -m32 -c $< -o $@


#$(ODIR64)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -DX64 -m64 -c $< -o $@

$(ODIRARM)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

irclient: client.c
$(CC) $(CPPFLAGS) $(CFLAGS) client.c -o irclient $(LDFLAGS)
Please note that you MUST indent with a TAB as shown
save and overwrite the file with CTRL-X

we are now ready to compile:

Code: Select all

sudo make
you maybe could get some warnings, but don't care...
if everythig went fine you should have irserver file in the current directory

irserver came with a internal www server witch is almost useless and crash often
a simple syntax to test it is: irserver <irTransLAN ip address>
try to run it, but first have it executable:

Code: Select all

sudo chmod +x irserver
sudo ./irserver 192.168.0.124
if you don't get any error.... we are supposed it is running, and it would be a good idea to running it as a daemon

Code: Select all

sudo ./irserver -daemon 192.168.0.124
IrServer to be used needs the GUICient (available for Mono/Windows/Mac) to learn iRCodes and populare the irDB on the server side
GUIClient use in quite simple, I will not talk about it here, but you can read the handbook

IRCLIENT SETUP
once you have learned all the needed irCodes and organized them in remote/commands, it's time to install irClient witch is needed to send commands to the server.
Like for the server, irClient for ARM cames in source code and needs to be compiled.
The process is almost the same:

Code: Select all

mkdir /home/pi/irclient
mkdir /home/pi/irclient/arm
cd /home/pi/irclient
wget http://www.irtrans.de/download/Client/irclient-src.tar.gz
tar -xvf irclient-src.tar.gz
now edit makefile

Code: Select all

nano makefile
and have it like this (you can copy this and delete the old lines)

Code: Select all

SHELL = /bin/sh

CC = gcc

CFLAGS = 
CPPFLAGS = -DLINUX 
LDFLAGS =
LIBS =
#ODIR = x86
#ODIR64 = x64
ODIRARM = arm

_OBJS = client.o
#OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
#OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))


#irclient: $(OBJS) 
#	$(CC) $(CFLAGS) $(OBJS) -m32 -o irclient $(LDFLAGS)

#irclient64: $(OBJS64)
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) -m64 -o irclient64 $(LDFLAGS)

irclient_arm: $(OBJSARM)
	$(CC) $(CFLAGS) $(OBJSARM) -o irclient $(LDFLAGS)


all: irclient irclient64

arm: irclient_arm


clean:
#	-rm $(OBJS)
#	-rm $(OBJS64)
	-rm $(OBJSARM)


#$(ODIR)/%.o: %.c flash.h errcode.h network.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -m32 -c $< -o $@


#$(ODIR64)/%.o: %.c flash.h errcode.h network.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -DX64 -m64 -c $< -o $@

$(ODIRARM)/%.o: %.c  flash.h errcode.h network.h remote.h makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
Remeber to indent with a TAB, save with CTRL-X , confirm overwrite
now, let's compile it!

Code: Select all

sudo make
we're almost done!...

now let's make it executable

Code: Select all

sudo chmod +x irclient
it's now time to test it!
the syntax is simple: irclient <ip> <remote> <command> where:
  • ip: the SERVER ip address (127.0.0.1 is your're running ir server on the same rPI), not hte LAN device ;)
  • remote: remote name you use in the GUI Client (ie: myskyhd)
  • command: learned irCode name under GUIClient (ie: KEY_POWER)
so the command should looks like

Code: Select all

./irclient 127.0.0.1 myskyhd KEY_POWER
that's all!

now let's integrate it in Domoticz! :D
after having create a virtual switch and named as you like (mine is 'TestIR'), create a LUA script (under events) name script_device_<something>.lua witch contain:

Code: Select all

commandArray = {}

- - change the name of the sensor
local sensor = 'TestIR'

if (devicechanged[sensor] == 'On') then
    os.execute ("/home/pi/irclient/irclient 127.0.0.1 myskyhd KEY_POWER")
end

return commandArray
...that's all
I home this would help!
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme »

uh.. I forgot....
I'm too much newbe to add instruction about how to run irserver at startup... if someone could integrate it I would really appreciate :P :P

=== EDIT ===
ok... I've just added the irserver startup string in the /etc/rc.local :P :P
The most dangerous phrase in any language is:
"We always done this way"
schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Apeldoorn
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 »

Running server as a deamon: do I need to setup 1 line for every irtrans unit? Or wil -LAN work?
Thank you for all the work you did. Very happy that now IRSERVER is working with domoticz
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme »

I got just one, so I don't really know... but running with LAN parameters hould issue the command to all IR device available in the network
The most dangerous phrase in any language is:
"We always done this way"
schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Apeldoorn
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 »

What exactly did you put in /etc/rc.local?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme »

./home/pi/irtrans/irserver -daemon 192.168.0.14 &

the IP represent my irtrans LAN device
The most dangerous phrase in any language is:
"We always done this way"
schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Apeldoorn
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 »

Thx a lot, now it is working. No experience with ubuntu, just followed your instructions.
schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Apeldoorn
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 »

Now we can sent ir commands from domoticz.
But is there a way to update the virtual switch based on received ir code?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme »

I don't think the receiver led can be used for other purpuse than learning ir codes.

This question should be addressed to irTrans directly :P

ciao
M
The most dangerous phrase in any language is:
"We always done this way"
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme »

at least I were able to create correctly the service for the iRserver... here's the How-To:

create the service file that would be store in /lib/systems/system/

Code: Select all

sudo nano /lib/systemd/system/irServer.service
copy into the following lines, check the right path and the right IP Address of your irTrans device

Code: Select all

[Unit]
Description=irTrans irServer Daemon
After=multi-user.target

[Service]
User=root
ExecStart=/home/pi/irserver/irserver -logfile /home/pi/irserver/irserver.log <Ip of Device>

[Install]
WantedBy=multi-user.target
save with Ctrl-X and confirm with Y
(note that the service should be NOT called with the -daemon option, otherwise it will fail)

now make it executable with:

Code: Select all

sudo chmod +x /lib/systemd/system/irserver.service
refresh the systemctl service, enable the service and start it

Code: Select all

sudo systemctl daemon-reload
sudo systemctl enable irserver.service
sudo systemctl start irserver.service
check the status with

Code: Select all

systemctl status irserver
it should be running, if not check the log file (mine is in /home/pi/irserver/irserver.log )
it is already up and running but if you want you can reboot the PI
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
atchoo
Posts: 1
Joined: Monday 02 April 2018 0:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by atchoo »

Hello,

Just wanted to mention that I managed to compile the latest version of irserver on Raspberry Pi - with all options except CCF.

I've tried many times to compile from the source code available for download on the irTrans website without luck, but today I found the CD that came along with my irTrans USB device, and I noticed that the source folder on the CD was newer (datestamped 2015). and boom - it worked (with minor adjustments).

Here's the contents of the makefile:

Code: Select all

SHELL = /bin/sh

CC = gcc

CFLAGS = 
CPPFLAGS = -DLINUX -DMEDIACENTER
LDFLAGS =   
LIBS =		libzip.a libz.a
LIBS64 =	libzip64.a libz64.a
ODIR = x86
ODIR64 = x64
ODIRARM = arm

_OBJS = fileio.o linuxserio.o lowlevel.o server.o errormessage.o flashrom.o webserver.o xap.o lanio.o ascii.o mce.o xbmc.o 
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))

irserver: $(OBJS) $(ODIR)/ccf.o 
	$(CC) $(CFLAGS) $(OBJS) $(LIBS) $(ODIR)/ccf.o -m32 -o irserver $(LDFLAGS)

irserver_noccf: $(OBJS) $(ODIR)/noccf.o
	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(ODIR)/noccf.o -m32 -o irserver $(LDFLAGS)

irserver64: $(OBJS64) $(ODIR64)/ccf.o 
	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(LIBS64) $(ODIR64)/ccf.o -m64 -o irserver64 $(LDFLAGS)

irserver64_noccf: $(OBJS64) $(ODIR64)/noccf.o
	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(LDFLAGS) $(ODIR64)/noccf.o -m64 -o irserver64 $(LDFLAGS)

irserver_arm: $(OBJSARM) $(ODIRARM)/noccf.o 
	$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/noccf.o -o irserver $(LDFLAGS)

irserver_arm_noccf: $(OBJSARM) $(ODIRARM)/noccf.o 
	$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/noccf.o -o irserver $(LDFLAGS)

all: irserver irserver64

arm: irserver_arm

arm_noccf: irserver_arm_noccf

clean:
	-rm $(OBJS) x86/noccf.o
	-rm $(OBJS64) x64/noccf.o
	-rm $(OBJSARM) arm/noccf.o


$(ODIR)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -m32 -c $< -o $@


$(ODIR64)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -DX64 -m64 -c $< -o $@

$(ODIRARM)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

irclient: client.c
	$(CC) $(CPPFLAGS) $(CFLAGS) client.c -o irclient $(LDFLAGS)
  • Code: Select all

    make irserver_arm
  • Got some compiler errors, but all of the fatal errors (which stopped the compiling) was related to references to "getdirentries64" and "off64_t" (64 bit equivalent functions).
  • Changed every reference to "getdirentries64" -> "getdirentries" and "off64_t" -> "off_t" in:
    fileio.c, server.c, ascii.c
  • Success! Copied the executable to same location as the previous one and named it irserver2 (just in case, so I could go back to the old one in case it went bonkers)
  • Updated the service file in "/lib/systemd/system" to point the new version of irserver and restarted the service
I've used it for the past 24 hours or so without problems whatsoever, so it seems to work nicely. :geek:

That said; this might be old news for all I know. I Just wanted to share this, because I have up until now used the irserver version I compiled a long time ago from the excellent guide in this thread.
However, if anyone's interested, I can upload a compiled version (or at least the source files) somewhere.

Best regards,

Andreas L.
Norway
JPingouix
Posts: 2
Joined: Monday 30 December 2019 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by JPingouix »

Hello,

Thanks for your post. I have made all the changes in fileio.c, server.c and ascii.c, but unfortunately I cannot resolve the following error when running make irserver_arm :

fileio.c:119:20: error: dereferencing pointer to incomplete type ‘struct dirent64’
fl = strlen (di -> d_name) - dlen;

I am using raspian 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux on a raspi3 B
Any idea ?
Thanks in advance for any help.

JPingouix, from Marseille (France)
JPingouix
Posts: 2
Joined: Monday 30 December 2019 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by JPingouix »

Hi!

Using the new makefile from Andreas L. (Thanks !) I finally succeeded with some more changes :

- Change all dirent64 to dirent in fileio.c, ascii.c and server.c
- add #define NO_FIRMWARE in server.c

And all is running fine on the very last of raspbian December 31, 2019.
Happy new year, folks ! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest