Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: How to identify string

by GrandFather (Sage)
on Mar 11, 2020 at 20:08 UTC ( #11114147=note: print w/replies, xml ) Need Help??


in reply to Re: How to identify string
in thread How to identify string

If the issue happens that infrequently then logging the error with as much context you can provide is the most sensible thing you can do.

The best fix is correcting the issue rather than dropping data on the floor and retrying. The worrying thing is that if you can get obvious corruption of messages you may also be able to get subtle corruption that looks OK to your tests on the receiving end, but is wrong. If you have control over both ends of the link you could change the message format to include error checking so that you have reasonable confidence that your data is reliable.

This is not a problem that we can sensibly help with without a lot more context. In the worst case this sort of problem can kill people and in some jurisdictions we could be held libel as a result of giving you unfortunate advice.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^3: How to identify string
by Acnapyx (Initiate) on Mar 12, 2020 at 13:02 UTC
    I don't think problem is in device, probably something with ENV. The script is simple:
    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);
    I saw something like this string "\x33\x35" on other project and I start thinking may be the problem is how data is delivered, like error how data is parsed or send and parsed like php urlencode something like that. I also because never see such a value in variable, don't know how is present there. Any suggestion ?

      You have provided an inconsistent fragment of the code you might be running. However I notice you are using Device::SerialPort. In the Example section of the documentation it says:

      It is recommended to always use "read(255)" due to some unexpected behavior with the termios under some operating systems (Linux and Solaris at least)

      Maybe that is a clue?

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-09-30 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (160 votes). Check out past polls.

    Notices?