From 17b9c7916bf644068013337a1d55005d4c599b67 Mon Sep 17 00:00:00 2001 From: ntruchsess Date: Thu, 8 May 2014 20:20:25 +0000 Subject: [PATCH] OWX: remove incorrectly added files 11_OWX_CCC.pm and 11_OWX_DS9097.pm git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5790 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/11_OWX_CCC.pm | 512 ------------------------------------- fhem/FHEM/11_OWX_DS9097.pm | 404 ----------------------------- 2 files changed, 916 deletions(-) delete mode 100644 fhem/FHEM/11_OWX_CCC.pm delete mode 100644 fhem/FHEM/11_OWX_DS9097.pm diff --git a/fhem/FHEM/11_OWX_CCC.pm b/fhem/FHEM/11_OWX_CCC.pm deleted file mode 100644 index ba06facea..000000000 --- a/fhem/FHEM/11_OWX_CCC.pm +++ /dev/null @@ -1,512 +0,0 @@ -######################################################################################## -# -# OWX_CCC.pm -# -# FHEM module providing hardware dependent functions for the COC/CUNO interface of OWX -# -# Prof. Dr. Peter A. Henning -# Norbert Truchsess -# -# $Id: 11_OWX_CCC.pm 2013-03 - pahenning $ -# -######################################################################################## -# -# Provides the following methods for OWX -# -# Alarms -# Complex -# Define -# Discover -# Init -# Reset -# Verify -# -######################################################################################## - -package OWX_CCC; - -use strict; -use warnings; - -######################################################################################## -# -# Constructor -# -######################################################################################## - -sub new($) { - my ($class) = @_; - - return bless { - interface => "COC/CUNO", - #-- module version - version => 4.0 - }, $class; -} - -######################################################################################## -# -# Public methods -# -######################################################################################## -# -# Define - Implements Define method -# -# Parameter def = definition string -# -# Return undef if ok, otherwise error message -# -######################################################################################## - -sub Define($) { - my ($self,$hash,$def) = @_; - - my @a = split("[ \t][ \t]*", $def); - - #-- check syntax - if(int(@a) < 3){ - return "OWX_CCC: Syntax error - must be define OWX " - } - my $dev = $a[2]; - - $hash->{DeviceName} = $dev; - #-- Second step in case of CUNO: See if we can open it - my $msg = "OWX_CCC: COC/CUNO device $dev"; - #-- hash des COC/CUNO - my $hwdevice = $main::defs{$dev}; - if($hwdevice){ - main::Log(1,$msg." defined"); - #-- store with OWX device - $self->{hwdevice} = $hwdevice; - #-- loop for some time until the state is "Initialized" - for(my $i=0;$i<6;$i++){ - last if( $hwdevice->{STATE} eq "Initialized"); - main::Log(1,"OWX_CCC: Waiting, at t=$i ".$dev." is still ".$hwdevice->{STATE}); - select(undef,undef,undef,3); - } - main::Log(1, "OWX_CCC: Can't open ".$dev) if( $hwdevice->{STATE} ne "Initialized"); - #-- reset the 1-Wire system in COC/CUNO - main::CUL_SimpleWrite($hwdevice, "Oi"); - - $dev = split('@',$dev); - #-- let fhem.pl MAIN call OWX_Ready when setup is done. - $main::readyfnlist{"$hash->{NAME}.$dev"} = $hash; - - return undef; - }else{ - main::Log(1, $msg." not defined"); - return $msg." not defined"; - } -} - -######################################################################################## -# -# Alarms - Find devices on the 1-Wire bus, which have the alarm flag set -# -# Return 0 because not implemented here. -# -######################################################################################## - -sub Alarms () { - my ($self) = @_; - - return 0; -} - -######################################################################################## -# -# Complex - Send match ROM, data block and receive bytes as response -# -# Parameter dev = ROM ID of device -# data = string to send -# numread = number of bytes to receive -# -# Return response, if OK -# 0 if not OK -# -######################################################################################## - -sub Complex ($$$) { - my ($self,$dev,$data,$numread) =@_; - - my $select; - my $res = ""; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - #-- has match ROM part - if( $dev ){ - #-- 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 reverse string id - $dev=~s/\.//g; - for(my $i=0;$i<8;$i++){ - $rom_id[7-$i]=substr($dev,2*$i,2); - } - $select=sprintf("Om%s%s%s%s%s%s%s%s",@rom_id); - main::Log(3,"OWX_CCC::Complex: sending match ROM to COC/CUNO ".$select) - if( $main::owx_debug > 1); - #-- - main::CUL_SimpleWrite($hwdevice, $select); - my ($err,$ob) = ReadAnswer($hwdevice); - #-- padding first 9 bytes into result string, since we have this - # in the serial interfaces as well - $res .= "000000000"; - } - #-- has data part - if ( $data ){ - $self->Send($data); - $res .= $data; - } - #-- has receive part - if( $numread > 0 ){ - #$numread += length($data); - main::Log(3,"OWX_CCC::Complex: COC/CUNO is expected to deliver $numread bytes") - if( $main::owx_debug > 1); - $res.=$self->Receive($numread); - } - main::Log(3,"OWX_CCC::Complex: returned from COC/CUNO $res") - if( $main::owx_debug > 1); - return $res; -} - -######################################################################################## -# -# Discover - Discover devices on the 1-Wire bus via internal firmware -# -# Return 0 : error -# 1 : OK -# -######################################################################################## - -sub Discover () { - my ($self) = @_; - - my $res; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - #-- zero the array - my @devs=(); - #-- reset the busmaster - $self->Init(); - #-- get the devices - main::CUL_SimpleWrite($hwdevice, "Oc"); - select(undef,undef,undef,0.5); - my ($err,$ob) = ReadAnswer($hwdevice); - if( $ob ){ - # main::Log(3,"OWX_CCC::Discover: ".$hwdevice->{NAME}." device search returns ".$ob); - foreach my $dx (split(/\n/,$ob)){ - next if ($dx !~ /^\d\d?\:[0-9a-fA-F]{16}/); - $dx =~ s/\d+\://; - my $ddx = substr($dx,14,2)."."; - #-- reverse data from culfw - for( my $i=1;$i<7;$i++){ - $ddx .= substr($dx,14-2*$i,2); - } - $ddx .= ".".substr($dx,0,2); - push (@devs,$ddx); - } - return \@devs; - } else { - main::Log(1, "OWX_CCC: No answer to ".$hwdevice->{NAME}." device search"); - return 0; - } -} - -######################################################################################## -# -# Init - Initialize the 1-wire device -# -# Return 1 or Errormessage: not OK -# 0 or undef: OK -# -######################################################################################## - -sub Init ($) { - my ($self,$hash) = @_; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - my $get = main::CallFn($hwdevice->{NAME}, "GetFn", $hwdevice, (" ", "raw", "ORm")); - return 1 if( !defined($get) ); - return 1 if( length($get) < 13); - return 1 unless ( substr($get,9,4) eq "OK" ); - - my ($ret,$ress); - my $name = $hash->{NAME}; - my $ress0 = "OWX_CCC::Detect: 1-Wire bus $name interface "; - $ress = $ress0; - - #-- get the interface - my $interface; - - select(undef,undef,undef,2); - #-- type of interface - main::CUL_SimpleWrite($hwdevice, "V"); - select(undef,undef,undef,0.01); - my ($err,$ob) = ReadAnswer($hwdevice); - #my $ob = CallFn($owx_hwdevice->{NAME}, "GetFn", $owx_hwdevice, (" ", "raw", "V")); - #-- process result for detection - if( !defined($ob)){ - $ob=""; - $ret=1; - #-- COC - }elsif( $ob =~ m/.*CSM.*/){ - $interface="COC"; - $ress .= "DS2482 / COC detected in $hwdevice->{NAME}"; - $ret=0; - #-- CUNO - }elsif( $ob =~ m/.*CUNO.*/){ - $interface="CUNO"; - $ress .= "DS2482 / CUNO detected in $hwdevice->{NAME}"; - $ret=0; - #-- something else - } else { - $ret=1; - } - #-- treat the failure cases - if( $ret == 1 ){ - $interface=undef; - $ress .= "in $hwdevice->{NAME} could not be addressed, return was $ob"; - } - #-- store with OWX device - $self->{interface} = $interface; - main::Log(1, $ress); - return $ret; -} - - -######################################################################################## -# -# Reset - Reset the 1-Wire bus -# -# Return 1 : OK -# 0 : not OK -# -######################################################################################## - -sub Reset () { - my ($self) = @_; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - my $ob = main::CallFn($hwdevice->{NAME}, "GetFn", $hwdevice, (" ", "raw", "ORb")); - - if( substr($ob,9,4) eq "OK:1" ){ - return 1; - }else{ - return 0 - } -} - -######################################################################################## -# -# Verify - Verify a particular device on the 1-Wire bus -# -# Parameter dev = 8 Byte ROM ID of device to be tested -# -# Return 1 : device found -# 0 : device not -# -######################################################################################## - -sub Verify ($) { - my ($self,$dev) = @_; - - my $i; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - #-- Ask the COC/CUNO - main::CUL_SimpleWrite($hwdevice, "OCf"); - #-- sleeping for some time - select(undef,undef,undef,3); - main::CUL_SimpleWrite($hwdevice, "Oc"); - select(undef,undef,undef,0.5); - my ($err,$ob) = $self->($hwdevice); - if( $ob ){ - foreach my $dx (split(/\n/,$ob)){ - next if ($dx !~ /^\d\d?\:[0-9a-fA-F]{16}/); - $dx =~ s/\d+\://; - my $ddx = substr($dx,14,2)."."; - #-- reverse data from culfw - for( my $i=1;$i<7;$i++){ - $ddx .= substr($dx,14-2*$i,2); - } - $ddx .= ".".substr($dx,0,2); - return 1 if( $dev eq $ddx); - } - } - return 0; -} - -####################################################################################### -# -# Private methods -# -######################################################################################## -# -# ReadAnswer - Replacement for CUL_ReadAnswer for better control -# -# Parameter: hash = hash of bus master -# -# Return: string received -# -######################################################################################## - -sub ReadAnswer($) -{ - my ($hwdevice) = @_; - - my $type = $hwdevice->{TYPE}; - - my $arg =""; - my $anydata=0; - my $regexp =undef; - - my ($mculdata, $rin) = ("", ''); - my $buf; - my $to = 3; # 3 seconds timeout - $to = $hwdevice->{RA_Timeout} if($hwdevice->{RA_Timeout}); # ...or less - for(;;) { - return ("Device lost when reading answer for get $arg", undef) - if(!$hwdevice->{FD}); - - vec($rin, $hwdevice->{FD}, 1) = 1; - my $nfound = select($rin, undef, undef, $to); - if($nfound < 0) { - next if ($! == EAGAIN() || $! == EINTR() || $! == 0); - my $err = $!; - main::DevIo_Disconnected($hwdevice); # TODO: DevIO_Disconnected sets hash on readyFnList! -> results in errors later as there's no ReadyFn in OWX - return("ReadAnswer $arg: $err", undef); - } - return ("Timeout reading answer for get $arg", undef) - if($nfound == 0); - $buf = main::DevIo_SimpleRead($hwdevice); - return ("No data", undef) if(!defined($buf)); - - - - if($buf) { - main::Log(5, "OWX_CCC::ReadAnswer $buf"); - $mculdata .= $buf; - } - - # \n\n is socat special - if($mculdata =~ m/\r\n/ || $anydata || $mculdata =~ m/\n\n/ ) { - if($regexp && $mculdata !~ m/$regexp/) { - main::CUL_Parse($hwdevice, $hwdevice, $hwdevice->{NAME}, $mculdata, $hwdevice->{initString}); - } else { - return (undef, $mculdata) - } - } - } -} - -######################################################################################## -# -# Receive - Read data from the 1-Wire bus -# -# Parameter: hash = hash of bus master, numread = number of bytes to read -# -# Return: string received -# -######################################################################################## - -sub Receive ($) { - my ($self,$numread) = @_; - - my $res=""; - my $res2=""; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - for( - my $i=0;$i<$numread;$i++){ - #main::Log(1, "Sending $hwdevice->{NAME}: OrB"; - #my $ob = CallFn($hwdevice->{NAME}, "GetFn", $hwdevice, (" ", "raw", "OrB")); - main::CUL_SimpleWrite($hwdevice, "OrB"); - select(undef,undef,undef,0.01); - my ($err,$ob) = ReadAnswer($hwdevice); - #main::Log(1, "Answer from $hwdevice->{NAME}:$ob: "; - - #-- process results - if( !(defined($ob)) ){ - return ""; - #-- four bytes received makes one byte of result - }elsif( length($ob) == 4 ){ - $res .= sprintf("%c",hex(substr($ob,0,2))); - $res2 .= "0x".substr($ob,0,2)." "; - #-- 11 bytes received makes one byte of result - }elsif( length($ob) == 11 ){ - $res .= sprintf("%c",hex(substr($ob,9,2))); - $res2 .= "0x".substr($ob,9,2)." "; - #-- 18 bytes received from CUNO - }elsif( length($ob) == 18 ){ - - my $res = "OWX_CCC::Receive: 18 bytes from CUNO: $ob\n"; - for(my $i=0;$i{NAME}); - } - } - main::Log(3, "OWX_CCC::Receive: $numread bytes = $res2 on bus ".$hwdevice->{NAME}) - if( $main::owx_debug > 1); - - return($res); -} - -######################################################################################### -# -# Send - Send data block -# -# Parameter hash = hash of bus master, data = string to send -# -# Return response, if OK -# 0 if not OK -# -######################################################################################## - -sub Send ($) { - my ($self,$data) =@_; - - my ($i,$j,$k); - my $res = ""; - my $res2 = ""; - - #-- get the interface - my $hwdevice = $self->{hwdevice}; - - for( $i=0;$i 1); -} - -1; \ No newline at end of file diff --git a/fhem/FHEM/11_OWX_DS9097.pm b/fhem/FHEM/11_OWX_DS9097.pm deleted file mode 100644 index 8ffe27c22..000000000 --- a/fhem/FHEM/11_OWX_DS9097.pm +++ /dev/null @@ -1,404 +0,0 @@ -######################################################################################## -# -# OWX_DS2480.pm -# -# FHEM module providing hardware dependent functions for the DS9097 interface of OWX -# -# Prof. Dr. Peter A. Henning -# Norbert Truchsess -# -# $Id: 11_OWX_SER.pm 2013-03 - pahenning $ -# -######################################################################################## -# -# Provides the following methods for OWX -# -# Alarms -# Complex -# Define -# Discover -# Init -# Reset -# Verify -# -######################################################################################## - -package OWX_DS9097; - -use strict; -use warnings; - -use constant { - QUERY_TIMEOUT => 1.0 -}; - -use vars qw/@ISA/; -@ISA='OWX_SER'; - -use ProtoThreads; -no warnings 'deprecated'; - -sub new($) { - my ($class,$serial) = @_; - - $serial->{pt_reset} = PT_THREAD(\&pt_reset); - $serial->{pt_block} = PT_THREAD(\&pt_block); - $serial->{pt_search} = PT_THREAD(\&pt_search); - - return bless $serial,$class; -} - -######################################################################################## -# -# The following subroutines in alphabetical order are only for a DS9097 bus interface -# -######################################################################################## -# -# Block_9097 - Send data block ( -# -# Parameter hash = hash of bus master, data = string to send -# -# Return response, if OK -# 0 if not OK -# -######################################################################################## - -sub pt_block ($) { - my ($thread,$self,$data) =@_; - PT_BEGIN($thread); - my $data2=""; - my $res=0; - for (my $i=0; $iTouchByte_9097(ord(substr($data,$i,1))); - $data2 = $data2.chr($res); - } - PT_EXIT($data2); - PT_END; -} - -######################################################################################## -# -# Query_9097 - Write to and read from the 1-Wire bus -# -# Parameter: hash = hash of bus master, cmd = string to send to the 1-Wire bus -# -# Return: string received from the 1-Wire bus -# -######################################################################################## - -sub Query_9097 ($) { - - my ($self,$cmd) = @_; - my ($i,$j,$k); - #-- get hardware device - my $hwdevice = $self->{hwdevice}; - - return undef unless (defined $hwdevice); - - $hwdevice->baudrate($self->{baud}); - $hwdevice->write_settings; - - if( $main::owx_debug > 2){ - my $res = "OWX_SER::Query_9097 Sending out "; - for($i=0;$i{name},3, $res); - } - - my $count_out = $hwdevice->write($cmd); - - main::Log3($self->{name},1, "OWX_SER::Query_9097 Write incomplete $count_out ne ".(length($cmd))."") if ( $count_out != length($cmd) ); - #-- sleeping for some time - select(undef,undef,undef,0.01); - - #-- read the data - my ($count_in, $string_in) = $hwdevice->read(48); - return undef if (not defined $string_in); - - if( $main::owx_debug > 2){ - my $res = "OWX_SER::Query_9097 Receiving "; - for($i=0;$i<$count_in;$i++){ - $j=int(ord(substr($string_in,$i,1))/16); - $k=ord(substr($string_in,$i,1))%16; - $res.=sprintf "0x%1x%1x ",$j,$k; - } - main::Log3($self->{name},3, $res); - } - - #-- sleeping for some time - select(undef,undef,undef,0.01); - - return($string_in); -} - -######################################################################################## -# -# ReadBit_9097 - Read 1 bit from 1-wire bus (Fig. 5/6 from Maxim AN214) -# -# Parameter hash = hash of bus master -# -# Return bit value -# -######################################################################################## - -sub ReadBit_9097 () { - my ($self) = @_; - - #-- set baud rate to 115200 and query!!! - my $sp1="\xFF"; - $self->{baud}=115200; - my $res=$self->Query_9097($sp1); - return undef if (not defined $res); - $self->{baud}=9600; - #-- process result - if( substr($res,0,1) eq "\xFF" ){ - return 1; - } else { - return 0; - } -} - -######################################################################################## -# -# OWX_Reset_9097 - Reset the 1-Wire bus (Fig. 4 of Maxim AN192) -# -# Parameter hash = hash of bus master -# -# Return 1 : OK -# 0 : not OK -# -######################################################################################## - -sub pt_reset () { - - my ($thread,$self)=@_; - - #-- Reset command \xF0 - my $cmd="\xF0"; - #-- write 1-Wire bus - PT_BEGIN($thread); - #-- write 1-Wire bus - my $res = $self->Query_9097($cmd); - PT_EXIT if (not defined $res); - #-- TODO: process result - #-- may vary between 0x10, 0x90, 0xe0 - PT_EXIT(1); - PT_END; -} - -######################################################################################## -# -# Search_9097 - Perform the 1-Wire Search Algorithm on the 1-Wire bus using the existing -# search state. -# -# Parameter hash = hash of bus master, mode=alarm,discover or verify -# -# Return 1 : device found, ROM number in owx_ROM_ID and pushed to list (LastDeviceFlag=0) -# or only in owx_ROM_ID (LastDeviceFlag=1) -# 0 : device not found, or ot searched at all -# -######################################################################################## - -sub pt_search ($) { - my ($thread,$self,$mode)=@_; - - PT_BEGIN($thread); - my ($sp1,$sp2,$response,$search_direction,$id_bit_number); - - #-- Response search data parsing operates bitwise - $id_bit_number = 1; - my $rom_byte_number = 0; - my $rom_byte_mask = 1; - my $last_zero = 0; - - #-- issue search command - $self->{baud}=115200; - #TODO: add specific command to search alarmed devices only - $sp2="\x00\x00\x00\x00\xFF\xFF\xFF\xFF"; - $response = $self->Query_9097($sp2); - return undef if (not defined $response); - $self->{baud}=9600; - #-- issue the normal search command \xF0 or the alarm search command \xEC - #if( $mode ne "alarm" ){ - # $sp1 = 0xF0; - #} else { - # $sp1 = 0xEC; - #} - - #$response = OWX_TouchByte($hash,$sp1); - - #-- clear 8 byte of device id for current search - @{$self->{ROM_ID}} =(0,0,0,0 ,0,0,0,0); - - while ( $id_bit_number <= 64) { - #loop until through all ROM bytes 0-7 - my $id_bit = $self->TouchBit_9097(1); - my $cmp_id_bit = $self->TouchBit_9097(1); - - #print "id_bit = $id_bit, cmp_id_bit = $cmp_id_bit\n"; - - if( ($id_bit == 1) && ($cmp_id_bit == 1) ){ - #print "no devices present at id_bit_number=$id_bit_number \n"; - next; - } - if ( $id_bit != $cmp_id_bit ){ - $search_direction = $id_bit; - } else { - # hä ? if this discrepancy if before the Last Discrepancy - # on a previous next then pick the same as last time - if ( $id_bit_number < $self->{LastDiscrepancy} ){ - if ((@{$self->{ROM_ID}}[$rom_byte_number] & $rom_byte_mask) > 0){ - $search_direction = 1; - } else { - $search_direction = 0; - } - } else { - # if equal to last pick 1, if not then pick 0 - if ($id_bit_number == $self->{LastDiscrepancy}){ - $search_direction = 1; - } else { - $search_direction = 0; - } - } - # if 0 was picked then record its position in LastZero - if ($search_direction == 0){ - $last_zero = $id_bit_number; - # check for Last discrepancy in family - if ($last_zero < 9) { - $self->{LastFamilyDiscrepancy} = $last_zero; - } - } - } - # print "search_direction = $search_direction, last_zero=$last_zero\n"; - # set or clear the bit in the ROM byte rom_byte_number - # with mask rom_byte_mask - #print "ROM byte mask = $rom_byte_mask, search_direction = $search_direction\n"; - if ( $search_direction == 1){ - @{$self->{ROM_ID}}[$rom_byte_number] |= $rom_byte_mask; - } else { - @{$self->{ROM_ID}}[$rom_byte_number] &= ~$rom_byte_mask; - } - # serial number search direction write bit - $response = $self->WriteBit_9097($search_direction); - # increment the byte counter id_bit_number - # and shift the mask rom_byte_mask-- - $id_bit_number++; - $rom_byte_mask <<= 1; - #-- if the mask is 0 then go to new rom_byte_number and - if ($rom_byte_mask == 256){ - $rom_byte_number++; - $rom_byte_mask = 1; - } - $self->{LastDiscrepancy} = $last_zero; - } - PT_EXIT(1); - PT_END; -} - -######################################################################################## -# -# TouchBit_9097 - Write/Read 1 bit from 1-wire bus (Fig. 5-8 from Maxim AN 214) -# -# Parameter hash = hash of bus master -# -# Return bit value -# -######################################################################################## - -sub TouchBit_9097 ($) { - my ($self,$bit) = @_; - - my $sp1; - #-- set baud rate to 115200 and query!!! - if( $bit == 1 ){ - $sp1="\xFF"; - } else { - $sp1="\x00"; - } - $self->{baud}=115200; - my $res=$self->Query_9097($sp1); - return undef if (not defined $res); - $self->{baud}=9600; - #-- process result - my $sp2=substr($res,0,1); - if( $sp1 eq $sp2 ){ - return 1; - }else { - return 0; - } -} - -######################################################################################## -# -# TouchByte_9097 - Write/Read 8 bit from 1-wire bus -# -# Parameter hash = hash of bus master -# -# Return bit value -# -######################################################################################## - -sub TouchByte_9097 ($) { - my ($self,$byte) = @_; - - my $loop; - my $result=0; - my $bytein=$byte; - - for( $loop=0; $loop < 8; $loop++ ){ - #-- shift result to get ready for the next bit - $result >>=1; - #-- if sending a 1 then read a bit else write 0 - if( $byte & 0x01 ){ - if( $self->ReadBit_9097() ){ - $result |= 0x80; - } - } else { - $self->WriteBit_9097(0); - } - $byte >>= 1; - } - return $result; -} - -######################################################################################## -# -# WriteBit_9097 - Write 1 bit to 1-wire bus (Fig. 7/8 from Maxim AN 214) -# -# Parameter hash = hash of bus master -# -# Return bit value -# -######################################################################################## - -sub WriteBit_9097 ($) { - my ($self,$bit) = @_; - - my $sp1; - #-- set baud rate to 115200 and query!!! - if( $bit ==1 ){ - $sp1="\xFF"; - } else { - $sp1="\x00"; - } - $self->{baud}=115200; - my $res=$self->Query_9097($sp1); - return undef if (not defined $res); - $self->{baud}=9600; - #-- process result - if( substr($res,0,1) eq $sp1 ){ - return 1; - } else { - return 0; - } -}; - -# dummy implementation of read - data is actually read within methods above. -sub read() { - return 1; -} - -1;