Wahoo! After a bit of goofing around and some pure luck I was able to make it work. I modified Win32::ComPort.pm, increasing the CP_Length from 64 to 66 as follows:
if (($CP_Length > 64) and ($self->{"_TYPE"} == PST_RS232)) {
to
if (($CP_Length > 66) and ($self->{"_TYPE"} == PST_RS232)) {
Then I installed Device::Modem and wrote the following:
#!perl
use strict;
#http://search.cpan.org/~cosimo/Device-Modem-1.51/
use Device::Modem;
my $port="COM9";
my $modem = new Device::Modem( port =>$port );
if($modem->connect( baudrate => 115200,databits=>8,parity=>'none',stop
+bits=>1 ) ) {
print "connected!\n";
}
else{
print "Error: Unable to connect with $port!.\n\t$!\n";
exit;
}
print "CMD->";
while(1){
my $cmd=<STDIN>;
if($cmd=~/^(x|q|exit|quit)$/is){last;}
$cmd =~s/[\r\n\t\s]+$//;
$cmd =~s/^[\r\n\t\s]+//;
$modem->atsend($cmd . Device::Modem::CR);
print $modem->answer();
}
#disconnect from the Modem
$modem->disconnect();
print "\nDONE\n";
And it all works. I am able to communicate to my usb device, passing it commands and seeing the returning answer.
Wahoo!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.