Hallo!

Thank You for the quick reply. In fact, I suspected the Event loop to make some trouble, so I moved the &testSequence() execution into an own thread. And the data fed by &testSequence() into the pipe is read and processed by the FSM -- once the pipes are fed from the bash. I have also tried to put the &testSequence() asleep for 1s in its initialisation to make sure the Event loop is started when the pipes are fed: the outcome is negative.

I open the pipes in "+<" mode, and already suspected this could be an issue. But since opening the pipes in &testSequence() did not seem to work and I did not get any error or warning when writing to the pipe, I was not alarmed.

Based on Your input, I have now tried opening the pipes in "+>" mode in &testSequence again: it makes no difference. :-( It looks to me like if the Event::IO was not notified, when the pipe is fed from the same process. Could it be?

Code Example

sub initAppControl () { my $config = shift; $config->{deviceControlCallback} = \&addDeviceControlCB; # create and open control FIFO if ('' eq (-p "$config->{fifoControl}->{status}" )) { POSIX::mkfifo ("$config->{fifoControl}->{status}", 0700); } if ('' eq (-p "$config->{fifoControl}->{control}" )) { POSIX::mkfifo ("$config->{fifoControl}->{control}", 0700); } # open pipes, set status pipe to "autoflush" open ($config->{fifo}->{appControl}->{control}, "+<", $config->{fif +oControl}->{control}) || die "Could not open status pipe ($!)\n"; open ($config->{fifo}->{appControl}->{status}, "+>", $config->{fifo +Control}->{status}) || die "Could not open control pipe ($!)\n"; $config->{fifo}->{appControl}->{status}->autoflush(1); } sub testSequence () { my $appControlFifo; my $deviceControlFifo; if ('' eq (-p "$sm->{config}->{deviceControl}" )) { POSIX::mkfifo ("$sm->{config}->{deviceControl}", 0700); } # shorthands for pipe handles open ($appControlFifo, "+>", $sm->{config}->{fifoControl}->{control +}) || die "Could not open status pipe for writing ($!)\n"; open ($deviceControlFifo, "+>", $sm->{config}->{deviceControl}) || +die "Could not open device pipe for writing ($!)\n"; $| = 1; $appControlFifo->autoflush(1); $deviceControlFifo->autoflush(1); # test sequence print $appControlFifo "connect to device\n"; # state transition: 01 + -> 02, currently automatically set print $appControlFifo "connect to device\n"; # keep current state print $appControlFifo "connect to device\n"; # keep current state print $appControlFifo "disconnect device\n"; print $deviceControlFifo "^MODE:1,1\n"; # state transition: 02 + -> 03 if ($sm->Instance() =~ "Statemachine::03") # check if transition +succeeded (kind of ASSERT) { print "transition succeeded\n"; } print $appControlFifo "connect to internet\n"; # state transition: +03 -> 04 print $appControlFifo "internet connected\n"; # state transition: 0 +3 -> 04 }

In reply to Re^2: testing of named pipes by lalu
in thread testing of named pipes by lalu

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.