• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Dataloging with the guruplug server  (Read 2333 times)
two9er
Jr. Member
**

Karma: 10
Posts: 51


View Profile
« on: May 19, 2010, 03:59:56 PM »

One of the main reasons I purchased the gplug was to log the output from my grid tied PV array. I have a fronius IG 3000 inverter http://www.fronius.com/cps/rde/xchg/SID-7042C1B4-F4045AC7/fronius_usa/hs.xsl/2714_1475.htm with an installed Interface Easy Card, which allows serial communication, albeit in some proprietary format. A kind soul named David Stone wrote a program called fslurp to access the data, and hosted it on sourceforge http://sourceforge.net/projects/fslurp/. fslurp needs to be compiled to obtain a binary executable, so I needed some dev tools.

Code:
apt-get install build-essential

fslurp compiled without errors, and all seemed good. The next step was to get serial access to the inverter. Out of my parts drawer I found a USB to serial dongle with no markings on it. Plugged it in, looked at dmesg, and found the following:

Code:
sheevaplug-debian:~# dmesg
<snip>
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for Handspring Visor / Palm OS
USB Serial support registered for Sony Clie 3.5
USB Serial support registered for Sony Clie 5.0
visor 1-1.3:1.0: Handspring Visor / Palm OS converter detected
usb 1-1.3: Handspring Visor / Palm OS converter now attached to ttyUSB0
usb 1-1.3: Handspring Visor / Palm OS converter now attached to ttyUSB1
usbcore: registered new interface driver visor
visor: USB HandSpring Visor / Palm OS driver
USB Serial support registered for KL5KUSB105D / PalmConnect
usbcore: registered new interface driver kl5kusb105d
kl5kusb105: v0.3a:KLSI KL5KUSB105 chipset USB->Serial Converter driver
<snip

Two ttyUSB devices? I never did figure that out, and it made it impossible (for me) to write a bash script to access it. Unplugging/replugging would then tie it to ttyUSB2, I ended up making an entry in /etc/modprobe.d/blacklist:

Code:
sheevaplug-debian:~# cat /etc/modprobe.d/blacklist | grep visor
blacklist visor

And now the dongle is identified as ttyUSB0 on bootup. I don't know the ramifications of blacklisting visor, maybe some day I'll find out. But wait, there's more! the gplug has two USB ports and I may plug any number of things into the vacant port and disrupt the naming sequence. So I created a udev rule which will link the USB/serial dongle to /dev/fronius upon bootup, or whenever it is plugged in. Extracting the information from udev:

Code:
sheevaplug-debian:~# udevinfo -p /sys/class/tty/ttyUSB2 -a

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/orion-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/platform/orion-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty':
    KERNELS=="tty"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '/devices/platform/orion-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="kl5kusb105d"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/platform/orion-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0':
    KERNELS=="1-1.3:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="kl5kusb105d"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="03"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v0830p0080d0100dcFFdsc00dp00icFFisc00ip00"
    ATTRS{supports_autosuspend}=="0"

  looking at parent device '/devices/platform/orion-ehci.0/usb1/1-1/1-1.3':
    KERNELS=="1-1.3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bMaxPower}==" 94mA"
    ATTRS{urbnum}=="6358"
    ATTRS{idVendor}=="0830"
    ATTRS{idProduct}=="0080"
    ATTRS{bcdDevice}=="0100"
    ATTRS{bDeviceClass}=="ff"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="4"
    ATTRS{version}==" 1.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Palm Computing, Inc."
    ATTRS{product}=="USB Serial Adaptor"
    ATTRS{serial}=="00447582"

  looking at parent device '/devices/platform/orion-ehci.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="138"
    ATTRS{idVendor}=="05e3"
    ATTRS{idProduct}=="0608"
    ATTRS{bcdDevice}=="7760"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="2"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="4"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{product}=="USB2.0 Hub"

  looking at parent device '/devices/platform/orion-ehci.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="24"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0002"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="1"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.32-00007-g56678ec ehci_hcd"
    ATTRS{product}=="Marvell Orion EHCI"
    ATTRS{serial}=="orion-ehci.0"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/platform/orion-ehci.0':
    KERNELS=="orion-ehci.0"
    SUBSYSTEMS=="platform"
    DRIVERS=="orion-ehci"
    ATTRS{modalias}=="platform:orion-ehci"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

I was able to write a rule in /etc/udev/rules.d/50-udev.rules:

Code:
sheevaplug-debian:~# cat /etc/udev/rules.d/50-udev.rules | grep fronius
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", ATTRS{serial}=="00447582", SYMLINK+="fronius"


Which gives me /dev/fronius

Code:
sheevaplug-debian:~# ls -l /dev | grep fronius
lrwxrwxrwx 1 root root           7 1969-12-31 17:00 fronius -> ttyUSB0

Now for the script. I needed to set the env variable TZ=America/Denver because a shell script executed by cron runs with limited variables, and I wanted the timestamp to be in local time.

Code:
sheevaplug-debian:~# cat fronius.sh
#!/bin/bash
TZ='America/Denver'; export TZ
/root/fslurp-0.6/fslurp -r all -d , -p /dev/fronius >> /media/sda1/fronius.log

And the crontab entry to get data once a minute:

Code:
sheevaplug-debian:~# cat /var/spool/cron/crontabs/root | grep fronius
* * * * * /root/fronius.sh

And a sample of the logfile:

Code:
sheevaplug-debian:~# tail -f /media/sda1/fronius.log
Wed May 19 16:15:01 2010,Wed May 19 16:15:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,915,3.75,244,59.98,5.37,181,12,2795,245,241,206,8.87,8349,2872,250,0,236,6080.33
Wed May 19 16:16:02 2010,Wed May 19 16:16:02 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,900,3.69,244,59.97,5.34,179,12,2795,245,241,206,8.88,8349,2872,250,0,236,6080.33
Wed May 19 16:17:02 2010,Wed May 19 16:17:02 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,892,3.64,245,59.98,5.41,179,12,2795,245,241,206,8.90,8349,2872,250,0,236,6080.33
Wed May 19 16:18:01 2010,Wed May 19 16:18:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,815,3.34,244,59.98,4.91,180,12,2795,245,241,206,8.92,8349,2872,250,0,236,6080.33
Wed May 19 16:19:01 2010,Wed May 19 16:19:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,883,3.63,244,59.99,4.97,193,12,2795,245,241,206,8.93,8349,2872,250,0,236,6080.33
Wed May 19 16:20:01 2010,Wed May 19 16:20:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,946,3.86,245,59.98,5.64,178,12,2795,245,241,206,8.95,8349,2872,250,0,236,6080.33
Wed May 19 16:21:01 2010,Wed May 19 16:21:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,1066,4.37,244,59.98,6.55,173,12,2795,245,241,206,8.97,8349,2872,250,0,236,6080.33
Wed May 19 16:22:01 2010,Wed May 19 16:22:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,1103,4.52,244,59.97,6.40,183,12,2795,245,241,206,8.98,8349,2872,250,0,236,6080.50
Wed May 19 16:23:01 2010,Wed May 19 16:23:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,1193,4.89,244,59.99,6.71,189,12,2795,245,241,206,9.00,8349,2872,250,0,236,6080.50
Wed May 19 16:24:01 2010,Wed May 19 16:24:01 2010,2,1.2.2,0x1,FRONIUS IG 3000 1-phase inverter,1240,5.08,244,59.96,7.36,179,12,2795,245,241,206,9.02,8349,2872,250,0,236,6080.50

FRONIUS IG 3000 1-phase inverter,915, is a sample of the current output in watts (yes it is snowing today in paradise!)

FWIW, Jim
 
Logged

Just plugging away! GuruPlug Server Plus, 1TB esata hd, 8GB microSD (rfs)

Pages: [1]
Print
Jump to: