SuperRoach Posted September 2, 2008 Share Posted September 2, 2008 Hello everyone First off, great community, been reading here for a while now.I'm making a led sign php program as a hobby, that will send messages when run. I've got a few ways to grab data, from a form, or rss feed.. but I can't seem to actually correctly send the data!Now the sign is connected on the network, and works correctly on ethernet. I just need to talk to it via udp via php.I have read up and determined fsock_open() should be the way to go, and I've written a small snippet below that will hopefully help with what im trying to do. When I run this, I don't get a connection to the sign, or anything at all. Am I missing something in the fwrite sign? Also, I need to write out a bunch of hex letters to send them correctly. I've used "\x01" to try and send them across, but could I use something like chr(01) as well?So again, I'm trying to use php to connect to a udp accepting sign, and then send a string to it correctly.http://pastie.org/263420 <?echo "<h1>LED sign sending r5</h1>Trying stuff out!";/* According to the Jetfile 2.4 specs for sending messages to led signs,I should be sending via udp, a predefined command which has its display in it. A lot of hex codes are required to do this. Is line 16 / $msg's hex syntax correct? */ $msg = "testmessage";echo signtest("10.0.0.27", 9520, $msg);function signtest ($ip, $port, $text) { [b]$fp = fsockopen("udp://$ip",$port, $errno, $errstr, 5);[/b] socket_set_timeout($fp,2); if (!$fp) { echo "Error:$errstr ($errno)<br>\n"; } else {[b] $msg = "\x01"."Z11"."\x02"."ETAA"."\x06"."\x1B"."0b"."0x1C"."1"."\x1A"."1".$text."\0x04";[/b] fwrite($fp,$msg); } $data = ''; while ($d = fread ($fp, 10000)) { $data .= $d; } fclose ($fp);// $data = preg_replace ("/....print\n/", "", $data);// $data = stripcolors ($data); return $data;}?> Any help or thoughts, would be greatly appreciated Link to comment Share on other sites More sharing options...
justsomeguy Posted September 2, 2008 Share Posted September 2, 2008 You could use chr instead of the escape notation. This is wrong though:"\0x04"Starting with 0 indicates an octal number, it should just start with x. Check the different characters you have in the string to make sure they're correct, I'm not sure if the string is actually what you want (i.e., should "0x1C" be "\x1C" or literal?). Link to comment Share on other sites More sharing options...
SuperRoach Posted September 3, 2008 Author Share Posted September 3, 2008 Thanks for the advice justsomeguy.I'll run the code again with the correct syntax for \x04 ....I'll be working on this for a while, so I might as well document the things im trying too:The jetfile specification is here:http://support.favotech.com/protocol.specs.2.4.jetfile.pdf (400kb)Page three has the example syntax for sending a basic string, which is: <0x01>ZXX<0x02>AA<0x06><0x1B>0b<0x1C>1<0x1A>1Test to display<0x04> in their own words: Notes: <0xXX> is for one hex code. For example, <0x30> is one ASCII code “0”Which is how I came to try the \x30 trick. I'll move to chr(xx) once I'm able to send to it correctly.I'm able to ping the sign on the network with 10.0.0.22, via the command prompt. I was trying to test I could replicate the ping with an example here:<?php$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);if (!$fp) { echo "ERROR: $errno - $errstr<br />\n";} else { fwrite($fp, "\n"); echo fread($fp, 26); fclose($fp);}?> (Example is from: http://www.webhostingtalk.com/showthread.php?t=645160 ).After modifying the example to point to the correct ip address though, It will time out.. Is there something I am missing there, as well? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 3, 2008 Share Posted September 3, 2008 That example is trying to connect on port 13, are you sure that port's open on the IP? Link to comment Share on other sites More sharing options...
SuperRoach Posted September 4, 2008 Author Share Posted September 4, 2008 It appears not. Updated code to be the correct syntax, is here: $text = "a string of random text";$msg = "\x01"."Z"."\x30"."\x02"."DTAAFILE"."\x06"."\x1B"."0b"."\x1C"."1"."\x1A"."1".$text."\x03"; Echo'ing message, it appears the hex code is working perfect which is neat.I can't communicate to the sign it appears though, even though I am able to ping it from the command prompt, and program it manually using the sigma software over ethernet.The ping code above does not work, with it just timing out for me. I noticed this article is right up there when trying to google for help on this topic too, which is kind of funny Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.