CUL commands added
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@313 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
1
CHANGED
1
CHANGED
@@ -474,3 +474,4 @@
|
|||||||
- bugfix: FileLog get (pgm2 plots) wont find the first row in the file
|
- bugfix: FileLog get (pgm2 plots) wont find the first row in the file
|
||||||
- feature: 00_CUL: Answer CUR requests (status/time/fht)
|
- feature: 00_CUL: Answer CUR requests (status/time/fht)
|
||||||
- bugfix: support for second correction factor for EMWZ in 15_CUL_EM added
|
- bugfix: support for second correction factor for EMWZ in 15_CUL_EM added
|
||||||
|
- feature: CUL further sets/gets added
|
||||||
|
|||||||
@@ -13,22 +13,29 @@ sub CUL_ReadAnswer($$);
|
|||||||
sub CUL_Ready($);
|
sub CUL_Ready($);
|
||||||
sub CUL_HandleCurRequest($$);
|
sub CUL_HandleCurRequest($$);
|
||||||
|
|
||||||
my $initstr = "X01"; # Only translated messages, no RSSI
|
my $initstr = "X21"; # Only translated messages + RSSI
|
||||||
my %msghist; # Used when more than one CUL is attached
|
my %msghist; # Used when more than one CUL is attached
|
||||||
my $msgcount = 0;
|
my $msgcount = 0;
|
||||||
my %gets = (
|
my %gets = (
|
||||||
"version" => "V",
|
"version" => "V",
|
||||||
"raw" => "",
|
"raw" => "",
|
||||||
"ccconf" => "=",
|
"ccconf" => "=",
|
||||||
|
"uptime" => "t",
|
||||||
);
|
);
|
||||||
|
|
||||||
my %sets = (
|
my %sets = (
|
||||||
"raw" => "",
|
"raw" => "",
|
||||||
|
"freq" => "",
|
||||||
|
"bWidth" => "",
|
||||||
|
"rAmpl" => "",
|
||||||
|
"sens" => "",
|
||||||
"verbose" => "X",
|
"verbose" => "X",
|
||||||
"freq" => "=",
|
"led" => "l",
|
||||||
"bandwidth" => "=",
|
"patable" => "x",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my @ampllist = (24, 27, 30, 33, 36, 38, 40, 42);
|
||||||
|
|
||||||
sub
|
sub
|
||||||
CUL_Initialize($)
|
CUL_Initialize($)
|
||||||
{
|
{
|
||||||
@@ -157,16 +164,15 @@ CUL_Set($@)
|
|||||||
my $f1 = sprintf("%02x", int($f % 65536) / 256);
|
my $f1 = sprintf("%02x", int($f % 65536) / 256);
|
||||||
my $f0 = sprintf("%02x", $f % 256);
|
my $f0 = sprintf("%02x", $f % 256);
|
||||||
$arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
|
$arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
|
||||||
my $msg = "Setting FREQ2..0 (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz, ".
|
my $msg = "Setting FREQ2..0 (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
|
||||||
"verbose to $initstr";
|
|
||||||
Log GetLogLevel($name,4), $msg;
|
Log GetLogLevel($name,4), $msg;
|
||||||
CUL_SimpleWrite($hash, "W0F$f2"); # Will reprogram the CC1101
|
CUL_SimpleWrite($hash, "W0F$f2");
|
||||||
CUL_SimpleWrite($hash, "W10$f1");
|
CUL_SimpleWrite($hash, "W10$f1");
|
||||||
CUL_SimpleWrite($hash, "W11$f0");
|
CUL_SimpleWrite($hash, "W11$f0");
|
||||||
CUL_SimpleWrite($hash, $initstr);
|
CUL_SimpleWrite($hash, $initstr); # Will reprogram the CC1101
|
||||||
return $msg;
|
return $msg;
|
||||||
|
|
||||||
} elsif($type eq "bandwidth") { # KHz
|
} elsif($type eq "bWidth") { # KHz
|
||||||
|
|
||||||
my $ob = 5;
|
my $ob = 5;
|
||||||
if(!IsDummy($hash->{NAME})) {
|
if(!IsDummy($hash->{NAME})) {
|
||||||
@@ -184,19 +190,47 @@ CUL_Set($@)
|
|||||||
goto GOTBW if($arg >= $bw);
|
goto GOTBW if($arg >= $bw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GOTBW:
|
GOTBW:
|
||||||
$ob = sprintf("%02x", $ob+$bits);
|
$ob = sprintf("%02x", $ob+$bits);
|
||||||
my $msg = "Setting MDMCFG4 (10) to $ob = $bw KHz, verbose to $initstr";
|
my $msg = "Setting MDMCFG4 (10) to $ob = $bw KHz";
|
||||||
|
|
||||||
Log GetLogLevel($name,4), $msg;
|
Log GetLogLevel($name,4), $msg;
|
||||||
CUL_SimpleWrite($hash, "W12$ob");
|
CUL_SimpleWrite($hash, "W12$ob");
|
||||||
CUL_SimpleWrite($hash, $initstr);
|
CUL_SimpleWrite($hash, $initstr);
|
||||||
return $msg;
|
return $msg;
|
||||||
|
|
||||||
} else {
|
} elsif($type eq "rAmpl") { # dB
|
||||||
|
|
||||||
|
return "a numerical value between 24 and 42 is expected"
|
||||||
|
if($arg !~ m/^\d+$/ || $arg < 24 || $arg > 42);
|
||||||
|
my ($v, $w);
|
||||||
|
for($v = 0; $v < @ampllist; $v++) {
|
||||||
|
last if($ampllist[$v] > $arg);
|
||||||
|
}
|
||||||
|
$v = sprintf("%02d", $v-1);
|
||||||
|
$w = $ampllist[$v];
|
||||||
|
my $msg = "Setting AGCCTRL2 (1B) to $v / $w dB";
|
||||||
|
CUL_SimpleWrite($hash, "W1D$v");
|
||||||
|
CUL_SimpleWrite($hash, $initstr);
|
||||||
|
return $msg;
|
||||||
|
|
||||||
|
} elsif($type eq "sens") { # dB
|
||||||
|
|
||||||
|
return "a numerical value between 4 and 16 is expected"
|
||||||
|
if($arg !~ m/^\d+$/ || $arg < 4 || $arg > 16);
|
||||||
|
my $w = int($arg/4)*4;
|
||||||
|
my $v = sprintf("9%d",$arg/4-1);
|
||||||
|
my $msg = "Setting AGCCTRL0 (1D) to $v / $w dB";
|
||||||
|
CUL_SimpleWrite($hash, "W1F$v");
|
||||||
|
CUL_SimpleWrite($hash, $initstr);
|
||||||
|
return $msg;
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
return "Expecting a 0-padded hex number"
|
return "Expecting a 0-padded hex number"
|
||||||
if((length($arg)&1) == 1 && $type ne "raw");
|
if((length($arg)&1) == 0 && $type ne "raw");
|
||||||
$initstr = "X$arg" if($type eq "verbose");
|
$initstr = "X$arg" if($type eq "verbose");
|
||||||
Log GetLogLevel($name,4), "set $name $type $arg";
|
Log GetLogLevel($name,4), "set $name $type $arg";
|
||||||
CUL_SimpleWrite($hash, $sets{$type} . $arg);
|
CUL_SimpleWrite($hash, $sets{$type} . $arg);
|
||||||
@@ -228,10 +262,10 @@ CUL_Get($@)
|
|||||||
my @answ = split(" ", CUL_ReadAnswer($hash, "C$a"));
|
my @answ = split(" ", CUL_ReadAnswer($hash, "C$a"));
|
||||||
$r{$a} = $answ[4];
|
$r{$a} = $answ[4];
|
||||||
}
|
}
|
||||||
$msg = sprintf("Freq:%.3fMHz Bwidth:%dKHz Ampl:%ddB Sens:%ddB",
|
$msg = sprintf("freq:%.3fMHz bWidth:%dKHz rAmpl:%ddB sens:%ddB",
|
||||||
26*(($r{"0D"}*256+$r{"0E"})*256+$r{"0F"})/65536, #Freq
|
26*(($r{"0D"}*256+$r{"0E"})*256+$r{"0F"})/65536, #Freq
|
||||||
26000/(8 * (4+(($r{"10"}>>4)&3)) * (1 << (($r{"10"}>>6)&3))), #Bw
|
26000/(8 * (4+(($r{"10"}>>4)&3)) * (1 << (($r{"10"}>>6)&3))), #Bw
|
||||||
$r{"1B"}&7<4 ? 24+3*($r{"1B"}&7) : 36+2*(($r{"1B"}&7)-4), #Ampl
|
$ampllist[$r{"1B"}],
|
||||||
4+4*($r{"1D"}&3) #Sens
|
4+4*($r{"1D"}&3) #Sens
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -551,7 +585,7 @@ CUL_Read($)
|
|||||||
$msghist{$msgcount}{MSG} = $dmsg;
|
$msghist{$msgcount}{MSG} = $dmsg;
|
||||||
$msgcount++;
|
$msgcount++;
|
||||||
|
|
||||||
if($initstr =~ m/X2/ && $dmsg =~ m/[A-F0-9][A-F0-9]$/) { # RSSI
|
if($initstr =~ m/X2/ && $dmsg =~ m/[FEHT]([A-F0-9][A-F0-9])+$/) { # RSSI
|
||||||
my $l = length($dmsg);
|
my $l = length($dmsg);
|
||||||
my $rssi = hex(substr($dmsg, $l-2, 2));
|
my $rssi = hex(substr($dmsg, $l-2, 2));
|
||||||
$dmsg = substr($dmsg, 0, $l-2);
|
$dmsg = substr($dmsg, 0, $l-2);
|
||||||
@@ -601,7 +635,7 @@ CUL_Read($)
|
|||||||
} elsif($fn eq "E") { # CUL_EM / Native
|
} elsif($fn eq "E") { # CUL_EM / Native
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
Log GetLogLevel($name,4), "CUL: unknown message $dmsg";
|
#Log GetLogLevel($name,4), "CUL: unknown message $dmsg";
|
||||||
goto NEXTMSG;
|
goto NEXTMSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1515,9 +1515,13 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
Issue a CUL firmware command. See the CUL firmware README document for
|
Issue a CUL firmware command. See the CUL firmware README document for
|
||||||
details on CUL commands.
|
details on CUL commands.
|
||||||
</li><br>
|
</li><br>
|
||||||
<li>freq / bandwidth<br>
|
<li>freq / bWidth / rAmpl / sens<br>
|
||||||
Set the CUL frequency / bandwidth. Use it with care, it may destroy
|
Set the CUL frequency / bandwidth / receiver-amplitude / sensitivity.
|
||||||
your hardware and it even may be illegal to do so.
|
Use it with care, it may destroy your hardware and it even may be
|
||||||
|
illegal to do so.
|
||||||
|
</li><br>
|
||||||
|
<li>led><br>
|
||||||
|
Set the CUL led off (00), on (01) or blinking (02).
|
||||||
</li><br>
|
</li><br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -1527,6 +1531,8 @@ A line ending with \ will be concatenated with the next one, so long lines
|
|||||||
<li>version<br>
|
<li>version<br>
|
||||||
return the CUL firmware version
|
return the CUL firmware version
|
||||||
</li><br>
|
</li><br>
|
||||||
|
<li>uptime<br>
|
||||||
|
return the CUL uptime (time since CUL reset).
|
||||||
<li>raw<br>
|
<li>raw<br>
|
||||||
Issue a CUL firmware command, and wait for one line of data returned by
|
Issue a CUL firmware command, and wait for one line of data returned by
|
||||||
the CUL. See the CUL firmware README document for details on CUL
|
the CUL. See the CUL firmware README document for details on CUL
|
||||||
|
|||||||
6
fhem.pl
6
fhem.pl
@@ -148,7 +148,7 @@ my %intAt; # Internal at timer hash.
|
|||||||
my $nextat; # Time when next timer will be triggered.
|
my $nextat; # Time when next timer will be triggered.
|
||||||
my $intAtCnt=0;
|
my $intAtCnt=0;
|
||||||
my $AttrList = "room comment";
|
my $AttrList = "room comment";
|
||||||
my $cvsid = '$Id: fhem.pl,v 1.61 2008-12-28 14:36:58 rudolfkoenig Exp $';
|
my $cvsid = '$Id: fhem.pl,v 1.62 2009-01-03 12:30:29 rudolfkoenig Exp $';
|
||||||
my $namedef =
|
my $namedef =
|
||||||
"where <name> is either:\n" .
|
"where <name> is either:\n" .
|
||||||
"- a single device name\n" .
|
"- a single device name\n" .
|
||||||
@@ -890,8 +890,8 @@ DoSet(@)
|
|||||||
my @a = @_;
|
my @a = @_;
|
||||||
|
|
||||||
my $dev = $a[0];
|
my $dev = $a[0];
|
||||||
return "No set implemented for $dev"
|
return "Please define $dev first" if(!$defs{$dev});
|
||||||
if(!$defs{$dev} || !$modules{$defs{$dev}{TYPE}}{SetFn});
|
return "No set implemented for $dev" if(!$modules{$defs{$dev}{TYPE}}{SetFn});
|
||||||
my $ret = CallFn($dev, "SetFn", $defs{$dev}, @a);
|
my $ret = CallFn($dev, "SetFn", $defs{$dev}, @a);
|
||||||
return $ret if($ret);
|
return $ret if($ret);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user