|
Posted by Spin on October 28, 2004, 11:52 am
Please log in for more thread options
I am using Device::Serialport 1.000002 on a RH 7.2 box, listening on
/dev/ttyS1 to a laboratory device.
I'm just getting going with this module and I'm finding the $ob-write()
a little erratic.
What is the nature of the data that is sent to the serial port?
This works fairly consistently (95% +):
$ob->write("x02x30x33x80x90x41x80x00x00x00x00x00x00x00x00x00x00x00x00x00x00xc1x03rn");
but this doesn't work consistently:
$ob->write(&ack_msg($loc));
where ack_msg is:
sub ack_msg {
my ($ack,$data,@array, $format, $i);
$data = unpack("a16"x(length($_[0])/16)."a*",$_[0]);
my($len) = int(16); # ACK message length constant
@array = unpack('C*', $data);
$_ = sprintf "%2.2x", $_ for @array;
$format = "%s%s%s%sn";
$data =~ tr/ |