View previous topic :: View next topic |
Author |
Message |
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Sun May 28, 2006 12:09 pm Post subject: Communicating with dos via website |
|
|
HI There
I need some help with a project I am doing.
I have a ProLite moving message disaply that I would like to hook up to my website to allow people to type messages that will scoll on the sign in my living room (sad I know, but fun never the less).
To control the sign you simply echo the message to the com port with the correct formatting.
I also have a little dos program the takes care of the formatting where the output to the sign is controlled like: pwrite "hello world"
Is there a way using abyss and php that I can capture test from my website and squirt it to either the dos echo command or pwrite.exe util?
I appreciate this might require some complicated work, but any pointers would be very useful.
With thanks
Paul |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Sun May 28, 2006 12:44 pm Post subject: |
|
|
That's brilliant thank you so much!
my first code:
led.php
Code: | <?php
$output = shell_exec('echo ^<ID01^> Web Test > com1');
echo "<pre>$output</pre>";
?> |
Had the desired result, my sign is now scrolling 'Web Test'
Code: | 'echo ^<ID01^> Web Test > com1' |
is the exact dos command to send the message ^<ID01^> being the code to select the first LED display
So I'm thinking that if I add a few more variables I could make this into slicker code to be included on a web page. I am new to php (onlt halfway thru teach yourself php in 10mins) so if you can help with my logic that would be great.
This is my thought progression, am I on the write track?
[setup]
$open = 'echo ^<ID01^>'
$message = **something captured from web**
$close = '> com1'
[send]
$output = shell_exec('$open' ' $message' '$close')
Thank you
Paul |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sun May 28, 2006 1:09 pm Post subject: |
|
|
You're on the right track.
Two problems:
For variables to get evaluated you have to use double quotes (""s). And you don't really need to use them in this case, you can just do $var.$var.
Secondly, to "join" to variables together you have to use periods. ("red".$green."blue".$yellow.$orange).
Also, you don't need to pad it out over multiple lines. (Although if it's easier then sure.)
Code: | if ($_GET['message'])
$output = shell_exec('echo ^<ID01^>'.$_GET['message'].' > com1');
# Would print out "Jelly" upon accessing my.page.php?message=Jelly. |
_________________
|
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Sun May 28, 2006 1:37 pm Post subject: |
|
|
Thanks MN that is working perfectly
Am I right in thinking I can set up a form to collect the value for $_GET, or should I replace $_GET with a new variable captured by the web form?
Sorry for the dumb questions but in 10 mins you have taught me more than reading this damn book in a week!
With gratitude
Paul |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Sun May 28, 2006 1:52 pm Post subject: |
|
|
Well, there are two ways to pass values over with forms.
They both have obvious advantaeges and disadvantages over eachother. (Post being less visibile, get being easier to manipulate for the end user.)
To use the code above, you could try something like:
Code: | <form action='<?=$_SERVER['PHP_SELF']?>' method=get> (<?=stuff?> is the equivelant to <?php echo stuff ?>, $_SERVER['PHP_SELF'] is the relative path to the current script.)
<input name='message' value=''><br>
<input type='submit' value='Change Message'>
</form>
<?php
if ($_GET['message'])
$output = shell_exec('echo ^<ID01^>'.$_GET['message'].' > com1');
?> |
To change that to use the post method, just replace $_GET with $_POST (Note that capitolization isn't important.), and change the form's method to post. _________________
|
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Sun May 28, 2006 2:02 pm Post subject: |
|
|
A-ha! I think I know where I have gotten confused as I have learnt POST and low and behold the next topic in the book is GET - duh!
I'm gonna read ahead a few more chapters before I ask for more help. Essentially you have whipped up the exact code I am after, now people can post message to my scrolling LED display (I'll post a url soon).
I want to expand this further to pull info from MySQL and display the number of users on my website, the cpu load etc but I have a heck load more reading and learning before I get there yet.
I can't thank you enough for your help, it had been so valuable and saved me hours of head scratching, you rock!
Paul
UPDATE: Temp url to send me a message is: http://viahome.co.uk
Messages will display on the LED sign in my lounge not on the webpage
UPDATE2: Thanks, the messages are coming through!
Just think of all the strange messages people could send :D
UPDATE3: Cheers for the messages MonkeyNation / TRUSTabyss.com
Last edited by PaulK on Sun May 28, 2006 7:09 pm; edited 3 times in total |
|
Back to top |
|
|
PaulK -
Joined: 26 Apr 2006 Posts: 132 Location: London, UK
|
Posted: Sun May 28, 2006 4:01 pm Post subject: |
|
|
Just like to thank everyone for the messages they are sending I am getting them all, some quite funny :)
Would anyone be interested in having a 'recent messages' displayed on the web or shall I keep it secret? |
|
Back to top |
|
|
|