mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-06 12:18:46 +00:00
usb tries to flash unflashed devices
git-svn-id: https://svn.fhem.de/fhem/trunk@1179 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ad730cee08
commit
9a410b2513
@ -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;
|
||||
}
|
||||
|
@ -164,10 +164,9 @@ CommandCULflash($$)
|
||||
my @a = split("[ \t]+", $param);
|
||||
return "Usage: CULflash <Fhem-CUL-Device> <CUL-type>, ".
|
||||
"where <CUL-type> 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;
|
||||
|
@ -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
|
||||
|
@ -79,6 +79,19 @@
|
||||
<a href="http://localhost:8084/fhem">http://fhem-host:8085/fhem</a> if
|
||||
you are using a tablet like the iPad.<br><br>
|
||||
|
||||
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.<br><br>
|
||||
|
||||
On linux (esp. FB7390) it will even try to
|
||||
flash the unflashed CUL, if it is attached at startup. See the <a
|
||||
href="commandref.html#usb">usb</a> and <a
|
||||
href="commandref.html#CULflash">CULflash</a> 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.<br><br>
|
||||
|
||||
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 <a href="commandref.html#CUL">CUL</a> a file named
|
||||
|
@ -738,14 +738,14 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
<b>Note:</b> dfu-programmer has to be installed in the path, this is
|
||||
already the case with the Fritz!Box 7390 image from fhem.de<br>
|
||||
|
||||
If the CUL is not yet flashed, then first define a <a href="#CUL">CUL</a>
|
||||
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.<br>
|
||||
If the CUL is not yet flashed, then specify "none" as CUL-Name.
|
||||
Example:
|
||||
<ul>
|
||||
<code>CULflash CUL CUL_V3</code>
|
||||
<code>CULflash CUL CUL_V3<br>
|
||||
CULflash none CUL_V3</code>
|
||||
</ul>
|
||||
Note: the message "dfu-programmer: failed to release interface 0." is
|
||||
normal on the FB7390.
|
||||
</ul>
|
||||
|
||||
|
||||
@ -1102,7 +1102,8 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
see the <a href="#FileLog">FileLog</a> section. Just apply the
|
||||
<code>archivecmd / archivedir / nrarchive</code> attributes to the
|
||||
<code>global</code> device as you would do for a FileLog device.<br>
|
||||
You can access the current name of the logfile with <code>{ $currlogfile }</code>.
|
||||
You can access the current name of the logfile with
|
||||
<code>{ $currlogfile }</code>.
|
||||
</li><br>
|
||||
|
||||
<a name="modpath"></a>
|
||||
@ -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.<br><br> This command
|
||||
is part of the autocreate module.
|
||||
feedback, and the devices will be created instead.<br><br>
|
||||
|
||||
Note that switching a CUL to HomeMatic mode is still has to be done
|
||||
manually.<br><br>
|
||||
|
||||
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.<br><br>
|
||||
|
||||
This command is part of the autocreate module.
|
||||
</ul>
|
||||
</ul> <!-- End of autocreate -->
|
||||
<br>
|
||||
@ -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 <a href="#notify">notify</a>.<br>
|
||||
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
|
||||
<ul>
|
||||
<device> <eventname>_avg_day: <computed_average>
|
||||
</ul>
|
||||
@ -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>
|
||||
</ul>
|
||||
at the beginning of the next day or month respectively.<br>
|
||||
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.
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user