As my request might have been too much asked, I have started doing some coding myself. I'm in doubt about the readline statement -which doesn't show anything received- as the meter sends continuously streams of 11 bytes Is there a way to just monitor with python what is arriving at a serial port?
#!/usr/bin/python #version 1-2-2012, script to read data from voltcraft vc940-meter import serial, time, os voltport='/dev/ttyUSB2' print "Be sure the Voltcraft is connected to ttyUSB2" print "Enter a filename:", filename = raw_input() voltdata = open(filename,'w') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, timeout=15) print "rs-232 parameters of Voltcraft: ", ser2 print "Opening " + ser2.portstr received=ser2.readline() print received print "Goodbye, data logged in file:" print filename ser2.close() # Close file voltdata.close() On 2 feb, 21:57, Jean Dupont <jeandupont...@gmail.com> wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly > in Python? > > thanks > Jean > > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); # wait 5ms per character > $port->read_const_time(200); # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > my ($nin, $in) = $port->read(255); > print $in; > > } > > $port->close; -- http://mail.python.org/mailman/listinfo/python-list