dshahin has asked for the wisdom of the Perl Monks concerning the following question:
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Serial port losing data
by roboticus (Chancellor) on Jul 14, 2007 at 04:09 UTC | |
|
Re: Serial port losing data
by GrandFather (Saint) on Jul 13, 2007 at 23:47 UTC | |
by dshahin (Pilgrim) on Jul 14, 2007 at 23:22 UTC | |
|
Re: Serial port losing data
by TOD (Friar) on Jul 13, 2007 at 23:30 UTC |