Skip to content

Commit

Permalink
Merge pull request #503 from marcmerlin/dtractive-warnings
Browse files Browse the repository at this point in the history
Show which dtr_active command failed if it happens.
  • Loading branch information
marcmerlin committed Apr 12, 2015
2 parents 0e4c64f + 2582018 commit 49cd4fa
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bin/test_x10
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $device->databits(8);
$device->baudrate(4800);
$device->parity("none");
$device->stopbits(1);
$device->dtr_active(1);
$device->dtr_active(1) or warn "Could not set dtr_active(1)";
$device->handshake("none");
$device->write_settings || die "Could not set up port\n";

Expand Down
2 changes: 1 addition & 1 deletion lib/AD2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ sub init {
$serial_port->stopbits(1);
$serial_port->handshake('none');
$serial_port->datatype('raw');
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);

select( undef, undef, undef, .100 ); # Sleep a bit
Expand Down
8 changes: 4 additions & 4 deletions lib/Compool.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ sub init

$serial_port->is_handshake("none"); #&? Should this be DTR?

$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
select (undef, undef, undef, .100); # Sleep a bit
::print_log "Compool init\n" if $main::Debug{compool};
Expand Down Expand Up @@ -647,15 +647,15 @@ sub send_command
# The API resets errors when reading status, $LatchErrorFlags
# is all $ErrorFlags since they were last explicitly cleared

#$serial_port->dtr_active(1);
#$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(1);
# select (undef, undef, undef, .05); # Sleep a bit
select (undef, undef, undef, .04); # Sleep a bit
if (17 == ($temp = $serial_port->write($Compool_Command_Header . $command . $Checksum)))
{
# select (undef, undef, undef, .02); # Sleep a bit
select (undef, undef, undef, .025); # Sleep a bit
#$serial_port->dtr_active(1);
#$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
print "Compool send command ok\n" if $main::Debug{compool} and $main::Debug{compool} >= 3;

Expand All @@ -668,7 +668,7 @@ sub send_command
{
# select (undef, undef, undef, .02); # Sleep a bit
select (undef, undef, undef, .05); # Sleep a bit
#$serial_port->dtr_active(1);
#$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
print "Compool send command failed sent " . $temp. " bytes\n";
return -1;
Expand Down
2 changes: 1 addition & 1 deletion lib/Concept.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sub init
$serial_port->parity("none");
$serial_port->stopbits(1);

$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(1);
select (undef, undef, undef, .100); # Sleep a bit
}
Expand Down
2 changes: 1 addition & 1 deletion lib/DSC5401.pm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ sub init {
$serial_port->stopbits(1);
$serial_port->handshake('none');
$serial_port->datatype('raw');
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);

#$serial_port->debug(0);
Expand Down
2 changes: 1 addition & 1 deletion lib/DSC_Alarm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sub init
$serial_port->parity("none");
$serial_port->stopbits(1);

$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
select (undef, undef, undef, .100); # Sleep a bit
}
Expand Down
2 changes: 1 addition & 1 deletion lib/FroggyRita.pm
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ sub init {
$serial_port->stopbits(2);
$serial_port->handshake('none');
$serial_port->datatype('raw');
$serial_port->dtr_active(0);
$serial_port->dtr_active(0) or warn "Could not set dtr_active(0)";
$serial_port->rts_active(1);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Insteon/PLMTerminal.pl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ =head1 SEE ALSO
$device->baudrate(19200);
$device->parity("none");
$device->stopbits(1);
$device->dtr_active(1);
$device->dtr_active(1) or warn "Could not set dtr_active(1)";
$device->handshake("none");
$device->read_char_time(0); # don't wait for each character
$device->read_const_time(RX_BLOCKTIME); # wait RX_BLOCKTIME (ms) per unfulfilled "read" call
Expand Down
2 changes: 1 addition & 1 deletion lib/Lynx10PLC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ sub serial_startup
$serial_port->databits(8);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
$serial_port->write_settings;
select (undef, undef, undef, .100); # Sleep a bit
Expand Down
2 changes: 1 addition & 1 deletion lib/Serial_Item.pm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ sub set_dtr {
my ($self, $state) = @_;
my $port_name = $self->{port_name};
if (my $serial_port = $main::Serial_Ports{$port_name}{object}) {
$main::Serial_Ports{$port_name}{object}->dtr_active($state);
$main::Serial_Ports{$port_name}{object}->dtr_active($state) or warn "Could not set dtr_active($state)";
print "Serial_port $port_name dtr set to $state\n" if $main::Debug{serial};
}
else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Stargate485.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sub init

$serial_port->handshake("none"); #&? Should this be DTR?

$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
select (undef, undef, undef, .100); # Sleep a bit
::print_log "Stargate485 init\n" if $main::Debug{Stargate485};
Expand Down
2 changes: 1 addition & 1 deletion lib/USB_UIRT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ sub usb_uirt_send {
push @bytes, $checksum;
$hex .= sprintf '%02x', $checksum;
print "USB_UIRT sending $hex\n";
$main::Serial_Ports{USB_UIRT}{object}->dtr_active(0);
$main::Serial_Ports{USB_UIRT}{object}->dtr_active(0) or warn "Could not set dtr_active(0)";
$main::Serial_Ports{USB_UIRT}{object}->write(pack 'C*', @bytes);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/X10_MR26.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sub check_for_data {

# Sending commands to another device on the same serial port may have dropped
# the DTR signal, so let the MR-26 know we're ready to recieve data again
$main::Serial_Ports{MR26}{object}->dtr_active(1);
$main::Serial_Ports{MR26}{object}->dtr_active(1) or warn "Could not set dtr_active(1)";

&main::check_for_generic_serial_data('MR26');
my $data = $main::Serial_Ports{MR26}{data_record};
Expand Down
2 changes: 1 addition & 1 deletion lib/Xantech.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sub init

#$serial_port->is_handshake("none"); #&? Should this be DTR?

$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(0);
select (undef, undef, undef, .100); # Sleep a bit
::print_log "Xantech init\n" if $main::Debug{xantech};
Expand Down
8 changes: 4 additions & 4 deletions lib/site/ControlX10/CM17.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ sub send_bits {
my @bits = split //, $bits;

# Reset the device
$serial_port->dtr_active(0);
$serial_port->dtr_active(0) or warn "Could not set dtr_active(0)";
$serial_port->rts_active(0);
select (undef, undef, undef, .100); # How long??


# Turn the device on
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(1);
select (undef, undef, undef, .20); # How long??

Expand All @@ -180,14 +180,14 @@ sub send_bits {
}
# Leave the device on till switch occurs ... emperically derived
# - 50->70 ms seemed to be the minnimum
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->rts_active(1);
select (undef, undef, undef, .150);

print " done\n" if $DEBUG;

# Turn the device off
$serial_port->dtr_active(0);
$serial_port->dtr_active(0) or warn "Could not set dtr_active(0)";
$serial_port->rts_active(0);

}
Expand Down
2 changes: 1 addition & 1 deletion lib/site/Device/SerialPort.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ Device::SerialPort - Linux/POSIX emulation of Win32::SerialPort functions.
$PortObj->purge_tx;
# controlling outputs from the port
$PortObj->dtr_active(T); # sends outputs direct to hardware
$PortObj->dtr_active(T) or warn "Could not set dtr_active(T)"; # sends outputs direct to hardware
$PortObj->rts_active(Yes); # return status of ioctl call
# return undef on failure
Expand Down
6 changes: 3 additions & 3 deletions lib/site/Win32API/CommPort.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2580,7 +2580,7 @@ Additional useful constants may be exported eventually.
$PortObj->purge_tx;
# controlling outputs from the port
$PortObj->dtr_active(T); # sends outputs direct to hardware
$PortObj->dtr_active(T) or warn "Could not set dtr_active(T)"; # sends outputs direct to hardware
$PortObj->rts_active(Yes); # returns status of API call
$PortObj->break_active(N); # NOT state of bit
Expand Down Expand Up @@ -2688,12 +2688,12 @@ when I<initialize> has completed successfully.
$PortObj->is_stopbits(1);
$PortObj->is_handshake("rts");
$PortObj->is_buffers(4096, 4096);
$PortObj->dtr_active(T);
$PortObj->dtr_active(T) or warn "Could not set dtr_active(T)";
@required = qw( BAUD DATA STOP PARITY );
$PortObj->initialize(@required) || undef $PortObj;
$PortObj->dtr_active(f);
$PortObj->dtr_active(f) or warn "Could not set dtr_active(f)";
$PortObj->is_baudrate(300);
$PortObj->close || die;
Expand Down
2 changes: 1 addition & 1 deletion lib/site/eg_cm11.plx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $serial_port->databits(8);
$serial_port->baudrate(4800);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->handshake("none");
$serial_port->write_settings || die "Could not set up port\n";

Expand Down
2 changes: 1 addition & 1 deletion lib/site/eg_cm17.plx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $serial_port->databits(8);
$serial_port->baudrate(4800);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->handshake("none");
$serial_port->write_settings || die "Could not set up port\n";

Expand Down
2 changes: 1 addition & 1 deletion lib/site/eg_ti103.plx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $serial_port->databits(8);
$serial_port->baudrate(19200);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->handshake("none");
$serial_port->write_settings || die "Could not set up port\n";

Expand Down
2 changes: 1 addition & 1 deletion lib/site/send_ti103.pl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$serial_port->baudrate(19200);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->dtr_active(1) or warn "Could not set dtr_active(1)";
$serial_port->handshake("none");
$serial_port->write_settings || die "Could not set up port\n";

Expand Down

0 comments on commit 49cd4fa

Please sign in to comment.