2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

Merge branch 'owx_async_protothreads'

git-svn-id: https://svn.fhem.de/fhem/trunk@5863 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2014-05-14 21:17:18 +00:00
parent 5e717b602c
commit eee034f149

View File

@ -160,49 +160,46 @@ sub pt_execute($$$$$$$) {
$self->reset() if ($reset);
$writedata = "" unless defined $writedata;
if (defined $writedata or $numread) {
my $select;
my $select;
#-- has match ROM part
if( $dev ){# command => EXECUTE,
# context => $context,
# reset => $reset,
# address => $owx_dev,
# writedata => $data,
# numread => $numread,
# delay => $delay
#-- has match ROM part
if( $dev ) {
#-- ID of the device
my $owx_rnf = substr($dev,3,12);
my $owx_f = substr($dev,0,2);
#-- ID of the device
my $owx_rnf = substr($dev,3,12);
my $owx_f = substr($dev,0,2);
#-- 8 byte 1-Wire device address
my @rom_id =(0,0,0,0 ,0,0,0,0);
#-- from search string to byte id
$dev=~s/\.//g;
for(my $i=0;$i<8;$i++){
$rom_id[$i]=hex(substr($dev,2*$i,2));
#-- 8 byte 1-Wire device address
my @rom_id =(0,0,0,0 ,0,0,0,0);
#-- from search string to byte id
$dev=~s/\.//g;
for(my $i=0;$i<8;$i++){
$rom_id[$i]=hex(substr($dev,2*$i,2));
}
$select=sprintf("\x55%c%c%c%c%c%c%c%c",@rom_id);
#-- has no match ROM part, issue skip ROM command (0xCC:)
} else {
$select="\xCC";
}
if (defined $writedata) {
$select.=$writedata;
}
#-- has receive data part
if( $numread ) {
#$numread += length($data);
for( my $i=0;$i<$numread;$i++){
$select .= "\xFF";
};
}
$select=sprintf("\x55%c%c%c%c%c%c%c%c",@rom_id).$writedata;
#-- has no match ROM part, issue skip ROM command (0xCC:)
} else {
$select="\xCC".$writedata;
}
#-- has receive data part
if( $numread ){
#$numread += length($data);
for( my $i=0;$i<$numread;$i++){
$select .= "\xFF";
};
}
#-- for debugging
if( $main::owx_async_debug > 1){
main::Log3($self->{name},3,"OWX_SER::Execute: Sending out ".unpack ("H*",$select));
#-- for debugging
if( $main::owx_async_debug > 1){
main::Log3($self->{name},3,"OWX_SER::Execute: Sending out ".unpack ("H*",$select));
}
$self->block($select);
}
$self->block($select);
PT_WAIT_UNTIL($self->response_ready());