use strict; use warnings; use Device::SerialPort; use HTTP::Tiny; sub send_msg { my ($self, $enccmd) = @_; my $pass = $oPrinter->write($enccmd) || return "Cannot communicate with Fiscal printer !"; my $timeout = 1; $oPrinter->read_char_time(0); $oPrinter->read_const_time(200); # Read_Total = read_const_time + (read_char_time * bytes_to_read) my $chars = 0; my $buffer = ""; while ($timeout > 0) { my ($count, $saw) = $oPrinter->read(1); if ($count > 0) { if (ord($saw) != 22) { $chars += $count; $buffer .= $saw; } } else { $timeout--; } } return $buffer; } my $test = $self->send_msg("\r\nGET NEW DATA\r\n"); my $url = "$self->{HOST}/report.php?fnac="; $url .= "$self->{unic}&num="; $url .= "$test"; my $response = HTTP::Tiny->new->get($url);