fhem + panStamp

Begonnen von Melchor, 26 September 2013, 12:19:42

Vorheriges Thema - Nächstes Thema

Melchor

I'm trying to run fhem with panStamp

I installed from tarball, http://www.dhs-computertechnik.de/downloads/fhem-cvs.tgz the latest development version (r3958)
I also installed "libxml-simple-perl"
I start from the directory where you have downloaded
perl fhem.pl fhem.cfg

fhem command:
define panStick panStamp /dev/ttyUSB0@38400

fhem gives me the log:

2013.09.26 11:34:19 1: Including fhem.cfg
2013.09.26 11:34:19 3: telnetPort: port 7072 opened
2013.09.26 11:34:19 3: WEB: port 8083 opened
2013.09.26 11:34:19 3: WEBphone: port 8084 opened
2013.09.26 11:34:19 3: WEBtablet: port 8085 opened
2013.09.26 11:34:19 3: Opening panStick device /dev/ttyUSB0
2013.09.26 11:34:19 3: Setting panStick baudrate to 38400
2013.09.26 11:34:19 3: panStick device opened
2013.09.26 11:34:24 1: Including ./log/fhem.save
2013.09.26 11:34:24 1: usb create starting
2013.09.26 11:34:24 1: usb create end
2013.09.26 11:34:24 0: Server started with 10 defined entities (version $Id: fhem.pl 3872 2013-09-07 11:58:33Z rudolfkoenig $, os linux, user mel, pid 4396)
2013.09.26 11:34:24 0: Undefined subroutine &main::XMLin called at ./FHEM/34_SWAP.pm line 108.

2013.09.26 11:34:24 0: ERROR: Cannot autoload SWAP
2013.09.26 11:34:24 3: panStick: Unknown code 000A001B000A000000000100000007, help me!


What is missing or what is wrong?
Thanks!

justme1968

the panstamp module is working and is receiving data. but something is wrong with XML::Simple and the swap module can not be loaded.

how did you install it? which platform are you on?

please try 'cpan install XML::Simple'.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Melchor

Hi, Andre,
thanks for your quick response
I'm in linux (mint15)

fhem installation I have done is downloading the latest development version and running it from its directory (I could not make install)

I have installed "cpan install XML::Simple"

continuing the same error

I launched lagarto running "lagarto-swap.py" and this works normally

when I launch "perl fhem.pl fhem.cfg" is when given the errors:

2013.09.26 14:56:04 0: Undefined subroutine &main::XMLin called at ./FHEM/34_SWAP.pm line 108.
2013.09.26 14:56:04 0: ERROR: Cannot autoload SWAP
2013.09.26 14:56:04 3: panStick: Unknown code 000D006E000D0C030702B0, help me!


in the terminal where I launched "perl fhem.pl fhem.cfg" appears:

Subroutine SWAP_Initialize redefined at ./FHEM/34_SWAP.pm line 74.
Subroutine SWAP_loadDevices redefined at ./FHEM/34_SWAP.pm line 97.
Subroutine readDeviceXML redefined at ./FHEM/34_SWAP.pm line 133.
Subroutine SWAP_Define redefined at ./FHEM/34_SWAP.pm line 203.
Subroutine SWAP_Undef redefined at ./FHEM/34_SWAP.pm line 273.
Subroutine SWAP_Set redefined at ./FHEM/34_SWAP.pm line 294.
Subroutine SWAP_Get redefined at ./FHEM/34_SWAP.pm line 566.
Subroutine SWAP_regName redefined at ./FHEM/34_SWAP.pm line 677.
Subroutine SWAP_readDeviceXML redefined at ./FHEM/34_SWAP.pm line 690.
Subroutine SWAP_Fingerprint redefined at ./FHEM/34_SWAP.pm line 708.
......


and, in the lagarto-swap.py terminal appears:

26-09-2013 21:57:31 SwapException occurred: Incomplete packet received.
Rved: (2A31)000A0031000A000000000100000007
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/swap/modem/SerialPort.py", line 83, in run
    raise SwapException("Serial port " + self.portname + " not available")
SwapException: 'SwapException occurred: Serial port /dev/ttyUSB0 not available'


I might be missing some configuration in fhem? I only ran the command define panStick panStamp /dev/ttyUSB0@38400

Can I have to throw SWAP otherwise?

I doubled the thread in the panstamp forum to be aware Daniel
Where you think it's better to continue?

justme1968

one importand thing: you can not run lagarto and fhem at the same time. only one of them can access the panstick device.

fhem works like this:

- you define the panstamp device. this you have done and it works.
- as soon as the panstamp receives the first message the module it will try to autocreate any other fhem device that you need.
- for this it will automaticaly load other fhem modules.
- for the binary output sketch this would be the generic swap module. this is the one using xml::simple and this is the one that fails.

please try this:perl -le 'use XML::Simple; print for %INC' on the comand line. it should show you at the bottom which file is included for xml::simple.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Melchor


$ perl -le 'use XML::Simple; print for %INC'
HTTP/Status.pm
/usr/share/perl5/HTTP/Status.pm
Time/Local.pm
/usr/share/perl/5.14/Time/Local.pm
warnings.pm
/usr/share/perl/5.14/warnings.pm
Encode/Locale.pm
/usr/share/perl5/Encode/Locale.pm
LWP/UserAgent.pm
/usr/share/perl5/LWP/UserAgent.pm
Fcntl.pm
/usr/lib/perl/5.14/Fcntl.pm
HTTP/Date.pm
/usr/share/perl5/HTTP/Date.pm
URI.pm
/usr/share/perl5/URI.pm
Exporter.pm
/usr/share/perl/5.14/Exporter.pm
HTTP/Response.pm
/usr/share/perl5/HTTP/Response.pm
warnings/register.pm
/usr/share/perl/5.14/warnings/register.pm
XSLoader.pm
/usr/share/perl/5.14/XSLoader.pm
I18N/Langinfo.pm
/usr/lib/perl/5.14/I18N/Langinfo.pm
Encode/Alias.pm
/usr/lib/perl/5.14/Encode/Alias.pm
Encode/Config.pm
/usr/lib/perl/5.14/Encode/Config.pm
Encode/Encoding.pm
/usr/lib/perl/5.14/Encode/Encoding.pm
LWP/MemberMixin.pm
/usr/share/perl5/LWP/MemberMixin.pm
Encode.pm
/usr/lib/perl/5.14/Encode.pm
base.pm
/usr/share/perl/5.14/base.pm
HTTP/Config.pm
/usr/share/perl5/HTTP/Config.pm
Config.pm
/usr/lib/perl/5.14/Config.pm
LWP.pm
/usr/share/perl5/LWP.pm
Carp.pm
/usr/share/perl/5.14/Carp.pm
bytes.pm
/usr/share/perl/5.14/bytes.pm
HTTP/Message.pm
/usr/share/perl5/HTTP/Message.pm
Exporter/Heavy.pm
/usr/share/perl/5.14/Exporter/Heavy.pm
vars.pm
/usr/share/perl/5.14/vars.pm
strict.pm
/usr/share/perl/5.14/strict.pm
HTTP/Request.pm
/usr/share/perl5/HTTP/Request.pm
constant.pm
/usr/share/perl/5.14/constant.pm
LWP/Protocol.pm
/usr/share/perl5/LWP/Protocol.pm
XML/Simple.pm
/usr/lib/perl5/XML/Simple.pm
overload.pm
/usr/share/perl/5.14/overload.pm
URI/Escape.pm
/usr/share/perl5/URI/Escape.pm
HTTP/Headers.pm
/usr/share/perl5/HTTP/Headers.pm
Storable.pm
/usr/lib/perl/5.14/Storable.pm

justme1968

could you please post the beginning of  /usr/lib/perl5/XML/Simple. pm.

thans
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Melchor


$ cat  /usr/lib/perl5/XML/Simple.pm|more
package LWP::Simple;

use strict;
use vars qw($ua %loop_check $FULL_LWP @EXPORT @EXPORT_OK $VERSION);

require Exporter;

@EXPORT = qw(get head getprint getstore mirror);
@EXPORT_OK = qw($ua);

# I really hate this.  I was a bad idea to do it in the first place.
# Wonder how to get rid of it???  (It even makes LWP::Simple 7% slower
# for trivial tests)
use HTTP::Status;
push(@EXPORT, @HTTP::Status::EXPORT);

$VERSION = "6.00";

sub import
{
    my $pkg = shift;
    my $callpkg = caller;
    Exporter::export($pkg, $callpkg, @_);
}

use LWP::UserAgent ();
use HTTP::Status ();
use HTTP::Date ();
$ua = LWP::UserAgent->new;  # we create a global UserAgent object
$ua->agent("LWP::Simple/$VERSION ");
$ua->env_proxy;


sub get ($)
{
    my $response = $ua->get(shift);
    return $response->decoded_content if $response->is_success;
    return undef;
}


sub head ($)
{
    my($url) = @_;
    my $request = HTTP::Request->new(HEAD => $url);
    my $response = $ua->request($request);

    if ($response->is_success) {
return $response unless wantarray;
return (scalar $response->header('Content-Type'),
scalar $response->header('Content-Length'),
HTTP::Date::str2time($response->header('Last-Modified')),
HTTP::Date::str2time($response->header('Expires')),
scalar $response->header('Server'),
      );
    }
    return;
}


sub getprint ($)
{
    my($url) = @_;
    my $request = HTTP::Request->new(GET => $url);
    local($\) = ""; # ensure standard $OUTPUT_RECORD_SEPARATOR
    my $callback = sub { print $_[0] };
    if ($^O eq "MacOS") {
$callback = sub { $_[0] =~ s/\015?\012/\n/g; print $_[0] }
    }
    my $response = $ua->request($request, $callback);
    unless ($response->is_success) {
print STDERR $response->status_line, " <URL:$url>\n";
    }
    $response->code;
}

justme1968

there is something different with your version. i'm not sure why.

please try the attached one. unpack it to /usr/lib/perl5/XML.

  andre

edit. i have checked my version with the one on cpan: http://search.cpan.org/~grantm/XML-Simple-2.20/lib/XML/Simple.pm. this is the one i use and you need. i have no idea about the version you have.
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Melchor

It works now !

I had installed
apt-get install libxml-simple-perl
and then
cpan install XML::Simple

Is it possible that this is the cause of the above problem?

_____________________________________

What is the next step?

fhem-2013-09.log:

2013.09.27 19:22:28 1: Including fhem.cfg
2013.09.27 19:22:28 3: telnetPort: port 7072 opened
2013.09.27 19:22:28 3: WEB: port 8083 opened
2013.09.27 19:22:28 3: WEBphone: port 8084 opened
2013.09.27 19:22:28 3: WEBtablet: port 8085 opened
2013.09.27 19:22:28 3: Opening panStick device /dev/ttyUSB0
2013.09.27 19:22:28 3: Setting panStick baudrate to 38400
2013.09.27 19:22:28 3: panStick device opened
2013.09.27 19:22:40 1: Including ./log/fhem.save
2013.09.27 19:22:40 1: usb create starting
2013.09.27 19:22:40 1: usb create end
2013.09.27 19:22:40 2: SecurityCheck:  WEB,WEBphone,WEBtablet has no basicAuth attribute. telnetPort has no password/globalpassword attribute.  Restart fhem for a new check if the problem is fixed, or set the global attribute motd to none to supress this message.
2013.09.27 19:22:40 0: Server started with 10 defined entities (version $Id: fhem.pl 3872 2013-09-07 11:58:33Z rudolfkoenig $, os linux, user mel, pid 2872)
2013.09.27 19:22:50 3: SWAP Unknown device 0C, please define it
2013.09.27 19:22:50 2: autocreate: define SWAP_0C SWAP 0C
2013.09.27 19:22:50 3: SWAP_0C: I/O device is panStick
2013.09.27 19:22:50 2: autocreate: define FileLog_SWAP_0C FileLog ./log/SWAP_0C-%Y.log SWAP_0C
2013.09.27 19:26:21 3: SWAP Unknown device 0D, please define it
2013.09.27 19:26:21 2: autocreate: define SWAP_0D SWAP 0D
2013.09.27 19:26:21 3: SWAP_0D: I/O device is panStick
2013.09.27 19:26:21 2: autocreate: define FileLog_SWAP_0D FileLog ./log/SWAP_0D-%Y.log SWAP_0D
2013.09.27 19:26:38 3: SWAP Unknown device 4A, please define it
2013.09.27 19:26:38 2: autocreate: define SWAP_4A SWAP 4A
2013.09.27 19:26:38 3: SWAP_4A: I/O device is panStick
2013.09.27 19:26:38 2: autocreate: define FileLog_SWAP_4A FileLog ./log/SWAP_4A-%Y.log SWAP_4A
2013.09.27 19:30:30 3: SWAP Unknown device 0B, please define it
2013.09.27 19:30:30 2: autocreate: define SWAP_0B SWAP 0B
2013.09.27 19:30:30 3: SWAP_0B: I/O device is panStick
2013.09.27 19:30:30 2: autocreate: define FileLog_SWAP_0B FileLog ./log/SWAP_0B-%Y.log SWAP_0B


I have connected the panStick and I have 3 Battery-board-DHT22 and a Output-board

It seems SWAP_0A is the Output-board

the menu everything shows :
....
SWAP
SWAP_06  ???
SWAP_0A  set-clearUnconfirmed
SWAP_0B  ???
SWAP_0C  ???
SWAP_0D  ???
SWAP_45  ???
SWAP_4A  ???
SWAP_8A  ???
...


and the other logs shows registers like "2013-09-27_20:52:02 SWAP_0B 0C: 02F10322"
the SWAP_0A-2013.log shows ".....2013-09-27_20:24:31 SWAP_0A 0B.8-Binary_7: 0
2013-09-27_20:24:31 SWAP_0A 0C-PWM_outputs: 00000000
2013-09-27_20:24:31 SWAP_0A 0C.1-PWM_output_0: 00 .....

How can I identify each endpoint?
How i read registers in 'human readable'?
How can i make a control ON-OFF?

(I have read the "device specific help" and http://fhem.de/HOWTO.html and http://www.fhemwiki.de/wiki/PanStamp)

Thanks.

justme1968

for the three battery boards the easiest way to get the human readable outputs is to press reset on each of them once. after that the temperature and humidity readings should be automatically created.

in the web interface you should then see a reading per endpoint for all boards. in the device summary on top of the page you should then also see all internal registers. something like this:

(siehe Anhang / see attachement)


(siehe Anhang / see attachement)


for the output board it would be good to use the binouts2 sketch instead of binouts. this will give one reading/register per output. you should then get separate readings like in the screenshot here: Link

you can connect to fhem via telnet to port 7072 and use the list <device> command. to switch them manualy use the regSet command. something like this:set <device> regSet 0B.1 1

the list of devices is still not correct. the best is probably to do a delete <device> for each of the SWAP_* devices and then press reset to auto create a new one.

hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

Melchor

Perfect!.

I have the human readable outputs.
The commands via fhem or telnet works.

I don't understand the avantages of binouts2, I think I have binouts, when i ask "list miDevice" :
...
 Product:
     label      Binary/PWM output module
     name       binouts
...

and the commands type "set miLed regSet 0B.8 0" works perfectly.

If you think I close the thread since the issue is resolved.

I still have doubts about other issues such as builtin frontend, but I will make another thread.

justme1968

the difference between binouts and binouts2 is that the first uses one swap register for all binary outputs combined and the second uses a dedicated swap register for each binary output.

this results in some differences in the handling of switching a single output as for the first sketch a single bit has to be logically combined with the bits of all other outputs to get the value to be send to the panstamp. in binouts all ports are independent which is much cleaner.

  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968