diff --git a/fhem/FHEM/98_autocreate.pm b/fhem/FHEM/98_autocreate.pm index f1c8bb7e4..d5641f416 100644 --- a/fhem/FHEM/98_autocreate.pm +++ b/fhem/FHEM/98_autocreate.pm @@ -289,7 +289,7 @@ my @usbtable = ( flush => "\n", request => "V\n", response => "^V .* CU.*", - define => "CUL_PARAM CUL DEVICE\@9600 1234", }, + define => "CUL_PARAM CUL DEVICE\@9600 1PARAM34", }, { NAME => "TCM310", matchList => ["cu.usbserial(.*)", "cu.usbmodem(.*)", "ttyUSB(.*)"], @@ -320,7 +320,7 @@ CommandUsb($$) my ($cl, $n) = @_; return "Usage: usb [scan|create]" if("$n" !~ m/^(scan|create)$/); - my $scan = 1 if($n =~ m/scan/); + my $scan = 1 if($n eq "scan"); my $ret = ""; my $msg; my $dir = "/dev"; @@ -331,6 +331,29 @@ CommandUsb($$) require "$attr{global}{modpath}/FHEM/DevIo.pm"; + ################ + # First try to flash unflashed CULs + if($^O eq "linux") { + # One device at a time to avoid endless loop + my $lsusb = `lsusb`; + my $culType; + $culType = "CUL_V4" if($lsusb =~ m/VID=03eb.PID=2ff0/s); # FritzBox + $culType = "CUL_V3" if($lsusb =~ m/VID=03eb.PID=2ff4/s); # FritzBox + $culType = "CUL_V2" if($lsusb =~ m/VID=03eb.PID=2ffa/s); # FritzBox + $culType = "CUL_V4" if($lsusb =~ m/03eb:2ff0/); + $culType = "CUL_V3" if($lsusb =~ m/03eb:2ff4/); + $culType = "CUL_V2" if($lsusb =~ m/03eb:2ffa/); + last if(!$culType); + $msg = "$culType: flash it with: CULflash none $culType"; + Log 4, $msg; $ret .= $msg . "\n"; + if(!$scan) { + CommandCULflash(undef, "none $culType"); + sleep(4); # Leave time for linux to load th drivers + } + } + + ################ + # Now the /dev scan foreach my $dev (sort split("\n", `ls $dir`)) { foreach my $thash (@usbtable) { foreach my $ml (@{$thash->{matchList}}) { @@ -383,7 +406,8 @@ CommandUsb($$) $define =~ s,DEVICE,$dir/$dev,g; $msg = "$dev: create as a fhem device with: define $define"; Log 4, $msg; $ret .= $msg . "\n"; - CommandDefine($cl, $define); + + CommandDefine($cl, $define) if($scan); goto NEXTDEVICE; } diff --git a/fhem/FHEM/99_updatefhem.pm b/fhem/FHEM/99_updatefhem.pm index ab336d470..69951549f 100644 --- a/fhem/FHEM/99_updatefhem.pm +++ b/fhem/FHEM/99_updatefhem.pm @@ -164,10 +164,9 @@ CommandCULflash($$) my @a = split("[ \t]+", $param); return "Usage: CULflash , ". "where is one of ". join(" ", sort keys %ctypes) - if(int(@a) != 2 || - !$defs{$a[0]} || - $defs{$a[0]}{TYPE} ne "CUL" || - !$ctypes{$a[1]}); + if(!(int(@a) == 2 && + ($a[0] eq "none" || ($defs{$a[0]} && $defs{$a[0]}{TYPE} eq "CUL")) && + $ctypes{$a[1]})); my $cul = $a[0]; my $target = $a[1]; @@ -202,8 +201,10 @@ CommandCULflash($$) $cmd =~ s/MCU/$mcu/g; $cmd =~ s/TARGET/$localfile/g; - CUL_SimpleWrite($defs{CUL}, "B01"); - sleep(4); # B01 needs 2 seconds for the reset + if($cul ne "none") { + CUL_SimpleWrite($defs{$cul}, "B01"); + sleep(4); # B01 needs 2 seconds for the reset + } Log 1, $cmd; my $result = `$cmd`; Log 1, $result; diff --git a/fhem/contrib/FB7390/startfhem b/fhem/contrib/FB7390/startfhem index 84e6ec4ba..c49173e76 100755 --- a/fhem/contrib/FB7390/startfhem +++ b/fhem/contrib/FB7390/startfhem @@ -17,15 +17,18 @@ export PATH export LD_LIBRARY_PATH=$home/lib export PERL5LIB=$home/lib/perl5/site_perl/5.12.2/mips-linux:$home/lib/perl5/site_perl/5.12.2:$home/lib/perl5/5.12.2/mips-linux:$home/lib/perl5/5.12.2 -# let FHEM run as user boxusr80 -# add user fhem with uid of boxusr80 +# let FHEM run as user boxusr80 by adding user fhem with uid of boxusr80 id fhem > /dev/null 2>&1 if [ "$?" -ne "0" ]; then echo "user fhem does not exist. Adding it." echo "fhem:any:1080:0:fhem:/home-not-used:/bin/sh" >>/var/tmp/passwd - # set files ownership + + # set file ownership chown -R boxusr80 ${home}/log chown -R boxusr80 ${home}/FHEM + + chown root ${home}/dfu-programmer + chmod 2755 ${home}/dfu-programmer fi perl fhem.pl fhem.cfg diff --git a/fhem/docs/HOWTO.html b/fhem/docs/HOWTO.html index 8027e80bf..9550e40d9 100644 --- a/fhem/docs/HOWTO.html +++ b/fhem/docs/HOWTO.html @@ -79,6 +79,19 @@ http://fhem-host:8085/fhem if you are using a tablet like the iPad.

+ In the default configuration, fhem will look for USB attached FHZ, CUL + and TCM devices on startup (unix/OSX only) and will create + appropriate fhem devices.

+ + On linux (esp. FB7390) it will even try to + flash the unflashed CUL, if it is attached at startup. See the usb and CULflash commands for details, and + check the "unsorted" room in FHEMWEB for the newly created + devices. Note that switching a CUL to HomeMatic mode is still has to be + done manually. Only one device is flashed per fhem-startup.

+ + For doing it manually (or if fhem failed to discover your device): Attach the USB device (CUL, FHZ1000PC/FHZ1300, TUL, EUL, etc) to your computer, and look for the corresponding device in the /dev directory. For CUL a file named diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index af839db86..e5378aad6 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -738,14 +738,14 @@ A line ending with \ will be concatenated with the next one, so long lines Note: dfu-programmer has to be installed in the path, this is already the case with the Fritz!Box 7390 image from fhem.de
- If the CUL is not yet flashed, then first define a CUL - device (even if fhem won't be able to open the device), insert it with the - button pressed (this will set the device into flash-mode), then issue the - CULflash command.
+ If the CUL is not yet flashed, then specify "none" as CUL-Name. Example:
    - CULflash CUL CUL_V3 + CULflash CUL CUL_V3
    + CULflash none CUL_V3
+ Note: the message "dfu-programmer: failed to release interface 0." is + normal on the FB7390. @@ -1102,7 +1102,8 @@ A line ending with \ will be concatenated with the next one, so long lines see the FileLog section. Just apply the archivecmd / archivedir / nrarchive attributes to the global device as you would do for a FileLog device.
- You can access the current name of the logfile with { $currlogfile }. + You can access the current name of the logfile with + { $currlogfile }.
@@ -7007,8 +7008,17 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U This command will scan the /dev directory for attached USB devices, and will try to identify them. With the argument scan you'll get back a list of fhem commands to execute, with the argument create there will be no - feedback, and the devices will be created instead.

This command - is part of the autocreate module. + feedback, and the devices will be created instead.

+ + Note that switching a CUL to HomeMatic mode is still has to be done + manually.

+ + On Linux it will also check with the lsusb command, if unflashed CULs are + attached. If this is the case, it will call CULflash with the appropriate + parameters (or display the CULflash command if scan is specified). Only + one device to flash is displayed at a time.

+ + This command is part of the autocreate module.
@@ -7030,7 +7040,8 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U The syntax for <regexp> is the same as the regexp for notify.
If it matches, and the event is of the form "eventname number", then this - module computes the daily and monthly average, and generates an event of the form + module computes the daily and monthly average, and generates an event of + the form
    <device> <eventname>_avg_day: <computed_average>
@@ -7039,7 +7050,8 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U <device> <eventname>_avg_month: <computed_average> at the beginning of the next day or month respectively.
- The current average and the cumulated values are stored in the device readings. + The current average and the cumulated values are stored in the device + readings.