|
Posted by Can2002 on 10/24/07 16:56
I've been trying to put together an application to change channel on a
media streaming server. The server is able to issue IR commands to
its attached equipment using LIRC, with commands being issued by a
socket connection to TCP/8765.
I put together a basic Python app that issued a command, which worked
fine. I wanted to create a fairly simple web interface and so set
about producing a similar simple PHP application. I've had limited
success so far, with the media server rejecting the connections.
Unfortunately I have limited access to the OS of the media server - I
just know that it recognises the commands from the Python app and
rejects the PHP one. I need to submit the following string:
SEND_ONCE pace_stb_5 rm_power
My PHP app (with all error checking removed) is as follows:
<?php
error_reporting(E_ALL);
echo "<h2>TCP/IP Connection</h2>\n";
$service_port = '8765';
$address = '192.168.1.100';
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$result = socket_connect($socket, $address, $service_port);
$out = '';
socket_send($socket, 'SEND_ONCE pace_stb_5 rm_power\n',
strlen('SEND_ONCE pace_stb_5 rm_power\n'));
echo $result . "OK<br />";
$out = socket_read($socket, 1024);
echo $out;
socket_close($socket);
?>
In case it's of use, my Python application is:
#!/usr/bin/python
import socket,string
def send_ir(host, port, command):
exterity=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
exterity.connect((host, port))
exterity.send(command+"\n")
while 1:
response = exterity.recv(1024)
if response.split('\n')[-2] == "END":
return response.split('\n')[1]
break
exterity-socket.close()
HOST = '192.168.1.100'
PORT = 8765
status = send_ir(HOST, PORT, 'SEND_ONCE pace_stb_5 rm_power')
print status
On the face of it it seems as though both apps are sending the same
string; however I'm wondering if they're submitting the strings in a
different way. Apologies if any of the above is vague; I'll happily
provide any additional information if needed!
Thanks in advance,
Chris
Navigation:
[Reply to this message]
|