Perhaps I should expand a little on what I'm trying to do. I tried to keep my original post down to the bare details.

For those who have not come across it, Scratch is a drag and drop programming language for kids. I'm trying to write an extension to it which can allow the control of Neopixels - programmable LEDs. The Scratch extension sends my custom command to a web server with all the parameters in a URL to a local web server. E.g. the scratch block tries to set pixel 2 with the RGB value 255,0,255 then the requested URL is:

/setneo/2/255/0/255

The hardware itself is being driven by an Arduino which I'm communicating with over a serial cable. Scratch can send the requests faster than the arduino can process them so I need my request handler to place them in a queue which will then be sequentially processed.

At the moment the queue processor is just the while loop at the end of the example I give, so it is in the same package. Currently it is just reporting on how big the queue is, but once it can see data from request_handler then it will expand to do something more useful.

If a global variable can not be used, then I could look at using a file as a processing queue, but that sounds messy. Is there any other way to share data between two forked processes? A future expansion might be for Scratch to wait until the Arduino has processed a command or accept an input from the Arduino, so eventually I might be looking at a two way communication between the two bits of code.


In reply to Re^2: Global variables and SimpleHTTP request handler by Anonymous Monk
in thread Global variables and SimpleHTTP request handler by Anonymous Monk

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.