culflash is using th "new" update directory structure now
git-svn-id: https://svn.fhem.de/fhem/trunk@2803 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -7,11 +7,10 @@ use warnings;
|
|||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
|
|
||||||
sub CommandCULflash($$);
|
sub CommandCULflash($$);
|
||||||
sub CULflash_SplitNewFiletimes($);
|
|
||||||
|
|
||||||
my $server = "http://fhem.de:80";
|
my $host = "http://fhem.de";
|
||||||
my $sdir = "/fhemupdate2";
|
my $path = "/fhemupdate4/svn/";
|
||||||
my $ftime = "filetimes.txt";
|
my $file = "controls_fhem.txt";
|
||||||
my $dfu = "dfu-programmer";
|
my $dfu = "dfu-programmer";
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@@ -50,18 +49,23 @@ CommandCULflash($$)
|
|||||||
|
|
||||||
################################
|
################################
|
||||||
# First get the index file to prove the file size
|
# First get the index file to prove the file size
|
||||||
my $filetimes = GetFileFromURL("$server$sdir/$ftime");
|
my $filetimes = GetFileFromURL("$host$path$file");
|
||||||
return "Can't get $ftime from $server" if(!$filetimes);
|
return "Can't get $host$path$file" if(!$filetimes);
|
||||||
|
|
||||||
# split filetime and filesize
|
my %filesize;
|
||||||
my ($ret, $filetime, $filesize) = CULflash_SplitNewFiletimes($filetimes);
|
foreach my $l (split("[\r\n]", $filetimes)) {
|
||||||
return $ret if($ret);
|
chomp($l);
|
||||||
|
next if ($l !~ m/^UPD (20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d) (\d+) (.*)$/);
|
||||||
|
$filesize{$3} = $2;
|
||||||
|
}
|
||||||
|
return "FHEM/$target.hex is not found in $host$path$file"
|
||||||
|
if(!$filesize{"FHEM/$target.hex"});
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Now get the firmware file:
|
# Now get the firmware file:
|
||||||
my $content = GetFileFromURL("$server$sdir/FHEM/$target.hex");
|
my $content = GetFileFromURL("$host$path/FHEM/$target.hex");
|
||||||
return "File size for $target.hex does not correspond to filetimes.txt entry"
|
return "File size for $target.hex does not correspond to $file entry"
|
||||||
if(length($content) ne $filesize->{"FHEM/$target.hex"});
|
if(length($content) ne $filesize{"FHEM/$target.hex"});
|
||||||
my $localfile = "$moddir/$target.hex";
|
my $localfile = "$moddir/$target.hex";
|
||||||
open(FH,">$localfile") || return "Can't write $localfile";
|
open(FH,">$localfile") || return "Can't write $localfile";
|
||||||
print FH $content;
|
print FH $content;
|
||||||
@@ -82,24 +86,6 @@ CommandCULflash($$)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
|
||||||
CULflash_SplitNewFiletimes($)
|
|
||||||
{
|
|
||||||
my $filetimes = shift;
|
|
||||||
my $ret;
|
|
||||||
my (%filetime, %filesize) = ();
|
|
||||||
foreach my $l (split("[\r\n]", $filetimes)) {
|
|
||||||
chomp($l);
|
|
||||||
$ret = "Corrupted filetimes.txt file"
|
|
||||||
if($l !~ m/^20\d\d-\d\d-\d\d_\d\d:\d\d:\d\d /);
|
|
||||||
last if($ret);
|
|
||||||
my ($ts, $fs, $file) = split(" ", $l, 3);
|
|
||||||
$filetime{$file} = $ts;
|
|
||||||
$filesize{$file} = $fs;
|
|
||||||
}
|
|
||||||
return ($ret, \%filetime, \%filesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
# vim: ts=2:et
|
# vim: ts=2:et
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|||||||
@@ -704,13 +704,11 @@ AnalyzeCommand($$)
|
|||||||
my ($fn, $param) = split("[ \t][ \t]*", $cmd, 2);
|
my ($fn, $param) = split("[ \t][ \t]*", $cmd, 2);
|
||||||
return undef if(!$fn);
|
return undef if(!$fn);
|
||||||
|
|
||||||
$fn = "setdefaultattr" if($fn eq "defattr"); # Compatibility mode
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# Search for abbreviation
|
# Search for abbreviation
|
||||||
if(!defined($cmds{$fn})) {
|
if(!defined($cmds{$fn})) {
|
||||||
foreach my $f (sort keys %cmds) {
|
foreach my $f (sort keys %cmds) {
|
||||||
if(length($f) > length($fn) && substr($f, 0, length($fn)) eq $fn) {
|
if(length($f) > length($fn) && lc(substr($f, 0, length($fn))) eq lc($fn)) {
|
||||||
Log 5, "$fn => $f";
|
Log 5, "$fn => $f";
|
||||||
$fn = $f;
|
$fn = $f;
|
||||||
last;
|
last;
|
||||||
@@ -721,8 +719,8 @@ AnalyzeCommand($$)
|
|||||||
#############
|
#############
|
||||||
# autoload commands.
|
# autoload commands.
|
||||||
if(!defined($cmds{$fn})) {
|
if(!defined($cmds{$fn})) {
|
||||||
map { $fn = $_ if(uc($fn) eq uc($_)); } keys %modules;
|
map { $fn = $_ if(lc($fn) eq lc($_)); } keys %modules;
|
||||||
$fn = lc(LoadModule($fn));
|
$fn = LoadModule($fn);
|
||||||
return "Unknown command $fn, try help" if(!defined($cmds{$fn}));
|
return "Unknown command $fn, try help" if(!defined($cmds{$fn}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user