Arjen de Korte wrote:

Although we're not getting the reply we expected, at least we're getting something (otherwise you would see an error or timeout message), so this isn't too bad. Most likely the controller is (unexpectedly) sending out empty lines before the reply. Please try the latest version from the SVN trunk, that is supposed to skip over replies that are shorter than 10 bytes. When running in debug level 4 (-DDDD), it will also show whatever we got in the reply.

yesterday I tried to track it down, mostly in serial.c (with some custom printf()s) with the following results:

- the F gets sent.
- the low level receive function returns 41, which is (estimated) the length of the response record from the SCD with CR+LF. - but the receive buffer seems to be empty. maybe some stray 0 byte in the start of the buffer ?

Since we're getting *something*, the connection seems to be fine.
it works without problems in minicom and with a simple perl script (see attachment), so it shouldn't be a wiring problem (while testing I made sure that no other app was accessing the port and the driver has r/w access to ttyS0).

I'm now writing this from memory, therefore sorry for the lack of detail; I'll check the latest version from svn in the late evening when I'm back home again and let you know my findings.

thanks & cu
#!/usr/bin/perl

use Device::SerialPort;

$LOGDIR    = "/home/rfu/log/";              # path to data file
$LOGFILE   = "scd.log";            # file name to output to
$PORT      = "/dev/ttyS0";          # port to watch

##
## Serial Settings
##

$ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!";
$ob->baudrate(1200)   || die "failed setting baudrate";
$ob->parity("none")    || die "failed setting parity";
$ob->databits(8)       || die "failed setting databits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings    || die "no settings";

##
## open the logfile, and Port
## 

open(LOG,">>${LOGDIR}/${LOGFILE}")
    ||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n";
open(DEV, "<$PORT") 
    || die "Cannot open $PORT: $_";

select(LOG), $| = 1;      # set nonbufferd mode

my $ctime = localtime();


## Loop forver, logging data to the log file
##

$pass=$ob->write("F");
while($_ = <DEV>){        # print input device to file
    print LOG "$ctime $_";
    sleep(180);
    $pass=$ob->write("F");
    $ctime = localtime();
    }

    undef $ob; 
_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to