I'm having a very frustrating problem talking to an serial-based cash register pole display. I'm working on a browser-based cash register that talks to a Perl daemon that sits on the localhost port 8080 and awaits messages that the browser sends by opening and closing a window with a localhost:8080 address and the text to display is encoded in the url in a RESTful manner.

The messages are getting to the daemon, but they don't consistently get to the LCD display. One time the message gets there, then next it might not. Sometimes half of $arg2 will display, sometimes none, sometimes all. Frustration!

I'm using : $SIG{'PIPE'} = 'IGNORE'; to keep the daemon from mysteriously failing, but I'm thinking that the problem is in HTTP::Daemon. Should I just break down and use apache on the localhost or perhaps Net::Daemon will work better?

Rather than hack away at possibilities I thought I'd post here and see if any fellow Monks have any experience with such matters.

Any insights would be appreciated.

Here's the HTTP::Daemon I'm using:

#!/usr/bin/perl use HTTP::Daemon; use HTTP::Status; my $d = HTTP::Daemon->new(LocalPort => 8080) || die; print "Please contact me at: <URL:", $d->url, ">\n"; $SIG{'PIPE'} = 'IGNORE'; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET' and $r->url->path =~ /display/) { my @args; my ($foo,$command,$arg1,$arg2) = split /\//, $r->url->pat +h; $arg1 =~ s/%20/ /g; $arg2 =~ s/%20/ /g; $arg1 = substr($arg1,0,20); print "command: $command arg1: $arg1 arg2:$arg2\n"; open SERIAL, ">>/dev/ttyS0" || die "Can't open serial"; select((select(SERIAL), $| = 1)[0]); print SERIAL "\x04\x01\x43\x31\x58\x17$arg1\x04\x01\x50\ +x44\x17 \$$arg2"; #print SERIAL "$$arg2 "; my $code = "200"; my $mess = "Cache-Control: no-cache"; $c->send_basic_header( $code, $mess ); close SERIAL; next; }elsif($r->method eq 'GET' and $r->url->path =~ /scroll/) { print SERIAL "\x04\x01\x44\x31\x33\x17";#DISPLAY DEMO }else { $c->send_error(RC_FORBIDDEN) } } $c->close; undef($c); }

In reply to Serial port losing data by dshahin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.