SDM120C how to for Arch ARM

Post Reply
jeanmarc
Posts: 1600
Joined: Thu Aug 29, 2013 7:16 am

SDM120C how to for Arch ARM

Post by jeanmarc » Thu Jun 18, 2015 9:31 am

Hi,

Here's the few steps to install the SDM10C com application for Arch ARM devices :

install first libmodbus (with: configure, make, make install)
Also do a pacman -Sy automake autoconf pkg-config

Add into the firsts lines of SDM120C's make file

Code: Select all

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
Then export LD_RUN_PATH=/usr/local/lib and make clean & make

ln -s /srv/http/metern/comapps/SDM120C/sdm120c /usr/bin/sdm120c

I use this pooling script (poolSDM485.sh) :

Code: Select all

#!/bin/bash

ADDRESS="$1"
BAUD_RATE="$2"
DEVICE="$3"

count=0
trap 'echo bye;rm /tmp/485live.txt;rm /tmp/485metern.txt; exit' EXIT SIGHUP SIGINT SIGQUIT SIGTERM 

while [ true ]; do

	VOLTAGE=""
	CURRENT=""
	POWER=""
	CURRENT=""
	POWERFACTOR=""
	FRQ=""
	RET=""

	CMD="sdm120c -a ${ADDRESS} -b ${BAUD_RATE} -p -v -c -f -g -e -i -t -q ${DEVICE}"
	VALUE=`$CMD`

	VOLTAGE=$(echo ${VALUE} | cut -d\  -f1)
	CURRENT=$(echo ${VALUE} | cut -d\  -f2)
	POWER=$(echo ${VALUE} | cut -d\  -f3)
	POWERFACTOR=$(echo ${VALUE} | cut -d\  -f4)
	FRQ=$(echo ${VALUE} | cut -d\  -f5)
	ENERGYIMPORT=$(echo ${VALUE} | cut -d\  -f6)
	ENERGYEXPORT=$(echo ${VALUE} | cut -d\  -f7)
	ENERGYTOT=$(echo ${VALUE} | cut -d\  -f8)
	RET=$(echo ${VALUE} | cut -d\  -f9)


	if [ "$RET" == "OK" ]; then
		count=0
		ID=$ADDRESS
		echo -e "$ID($VOLTAGE*V)\n$ID($CURRENT*A)\nTOT($POWER*W)\n$ID($POWERFACTOR*F)\n$ID($FRQ*Hz)" > /tmp/485live.txt
		echo -e "EIMP($ENERGYIMPORT*Wh)\nEEXP($ENERGYEXPORT*Wh)" > /tmp/485metern.txt
	else
		count=$(expr $count + 1)
		if [ $count -ge 100 ]; then
			rm /tmp/485live.txt
			rm /tmp/485metern.txt
			count=0
		fi
#		echo -e "$ID(0*V)\n$ID(0*A)\nTOT(0*W)\n$ID(0*F)\n$ID(0*Hz)" > /tmp/485live.txt
#		timestamp=$(date +"%Y-%m-%d %H:%M:%S")
#		echo "$timestamp $VALUE" >> /tmp/485meter.err

	fi
	sleep 0.5
done
chmod +x /srv/http/metern/comapps/SDM120C/poolSDM485.sh
ln -s /srv/http/metern/comapps/SDM120C/poolSDM485.sh /usr/bin/poolSDM485

You may start this daemon via metern/scripts/comappsdaemon.php.
Eg to request the values

Code: Select all

more /tmp/485metern.txt | egrep "^EIMP\(" | grep "*Wh)"
more /tmp/485live.txt | egrep "^1\(" | grep "*Hz)"
..
Have fun and thanks gianfrdp 8-)

ginorosi
Posts: 22
Joined: Sun Jun 22, 2014 10:47 pm

Re: SDM120C how to for Arch ARM

Post by ginorosi » Thu Oct 08, 2015 10:06 am

Hi JM
I have a pogoplug with Arch , i have installed libmodbus from here http://libmodbus.org/download/ and install ok , the example is runnig without errors , but when install sdm120c i have this errors :
[root@cagacazzo SDM120C]# export LD_RUN_PATH=/usr/local/lib
[root@cagacazzo SDM120C]# make clean
rm -f *.o sdm120c
[root@cagacazzo SDM120C]# make
gcc -c -o sdm120c.o sdm120c.c `pkg-config --cflags libmodbus`
gcc -o sdm120c sdm120c.o `pkg-config --libs libmodbus`
sdm120c.o: In function `getMeasureFloat':
sdm120c.c:(.text+0xa5c): undefined reference to `exit_error'
sdm120c.o: In function `getConfigBCD':
sdm120c.c:(.text+0xcf0): undefined reference to `exit_error'
sdm120c.o: In function `changeConfigFloat':
sdm120c.c:(.text+0xf34): undefined reference to `exit_error'
sdm120c.o: In function `changeConfigBCD':
sdm120c.c:(.text+0x10a8): undefined reference to `exit_error'
sdm120c.o: In function `main':
sdm120c.c:(.text+0x2484): undefined reference to `exit_error'
sdm120c.o:sdm120c.c:(.text+0x2fd4): more undefined references to `exit_error' follow
collect2: error: ld returned 1 exit status
Makefile:12: recipe for target 'sdm120c' failed
make: *** [sdm120c] Error 1
SDM120C i download with GIT ,
Where is the problem ?

Thank's

jeanmarc
Posts: 1600
Joined: Thu Aug 29, 2013 7:16 am

Re: SDM120C how to for Arch ARM

Post by jeanmarc » Thu Oct 08, 2015 10:20 am

Hi,
Did you edit the SDM120C make file ?

ginorosi
Posts: 22
Joined: Sun Jun 22, 2014 10:47 pm

Re: SDM120C how to for Arch ARM

Post by ginorosi » Thu Oct 08, 2015 10:37 am

Yes , add 2 line at top of Makefile ,
maybe the author of 120c is changed from your installation ?

I post the question also here http://www.energeticambiente.it/tecnica ... 20-10.html

by

jeanmarc
Posts: 1600
Joined: Thu Aug 29, 2013 7:16 am

Re: SDM120C how to for Arch ARM

Post by jeanmarc » Thu Oct 08, 2015 11:07 am

Yes there is the problem here as well.. :|

ginorosi
Posts: 22
Joined: Sun Jun 22, 2014 10:47 pm

Re: SDM120C how to for Arch ARM

Post by ginorosi » Fri Oct 09, 2015 10:17 am

we wait ! Gianfrd not available from a week . :(

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest