vrn has asked for the wisdom of the Perl Monks concerning the following question:
Test results for time difference between CMD1 and CorrRsp: Test1: 116 ms; test2: 105 ms; test3: 69 ms; test4: 79 ms; test5: 97 ms; test6: 69 ms; test7: 99 ms; test8: 76 ms;#!/usr/bin/perl use Win32::SerialPort; use Time::HiRes qw(usleep); $com="COM1"; $PortObj=Win32::SerialPort->new($com); $PortObj->baudrate(38400); $PortObj->databits(8); $PortObj->parity("none"); $PortObj->stopbits(1); $PortObj->handshake("xoff"); $PortObj->xon_limit(100); # bytes left in buffer $PortObj->xoff_limit(100); # space left in buffer $PortObj->xon_char(0x11); $PortObj->xoff_char(0x13); $PortObj->read_interval(2); # max time between read char (milliseco +nds) $PortObj->read_char_time(1); # avg time between read char $PortObj->read_const_time(2); # total = (avg * bytes) + const #writes the settings into the port $PortObj->write_settings; $PortObj->are_match("CorrRsp", ""); # correct response for CMD1 my $gotit = ""; until ("" ne $gotit) { $gotit = $PortObj->lookfor(100); #blocking read if($gotit){last;} $cmd= "CMD1\n"; # CMD1 Send in loop till CorrRsp is received $PortObj->write($cmd); $microseconds = "600"; usleep ($microseconds); } $cmd= "CMD2\n"; $PortObj->write($cmd); print("$gotit\n"); $mydata1 = $gotit; $PortObj->close; undef $PortObj;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Timing issue while accessing serial port
by Marshall (Canon) on Jan 20, 2011 at 10:45 UTC | |
by vrn (Initiate) on Feb 02, 2011 at 06:21 UTC | |
|
Re: Timing issue while accessing serial port
by dasgar (Priest) on Jan 20, 2011 at 14:10 UTC | |
by Marshall (Canon) on Jan 20, 2011 at 14:22 UTC | |
by vrn (Initiate) on Feb 02, 2011 at 06:56 UTC | |
|
Re: Timing issue while accessing serial port
by Marshall (Canon) on Jan 20, 2011 at 13:07 UTC | |
|
Re: Timing issue while accessing serial port
by Phemto (Acolyte) on Jan 20, 2011 at 10:27 UTC | |
by Marshall (Canon) on Jan 20, 2011 at 10:57 UTC |