Search the Community
Showing results for tags 'Websocket'.
-
I configured my Raspberry Pi as a LAMP server. I have LEDs connected to my RP and can control them with c/c++ programs. Now I want to built a web interface to control the colors of my LEDs. For my first attempt I used JQuery to send different commands to a PHP script that would execute a program with the color as a parameter. This doesn't seems to be the best solution, because I'm pretty limited on any effects I can make. So my second idea was to use sockets to send information to my program. This means my ledControler program listens for incoming commands and executes them. For this I used Websockets, but since I didn't use a library for my c++ program, it was very painfull to implement the whole WebSocket RFC. Another idea was to use PHP sockets. But I didn't test it out. My question is, am doing this completely wrong? Is there a simpler preferred way to do this?
-
I have created a Websocket between my webpage and a application acting like a server on my computer. And the program is sending data though the Websocket, but i am trying to display it. When i open the page in the Chrome Developers Tools i get this. {"message":"SIMCONNECT_RECV_ID_SIMOBJECT_DATA","value":{"COM1_A":128.250000,"COM1_S":128.300003,"COM2_A":127.800003,"COM2_S":127.900002,"NAV1_A":108.500000,"NAV1_S":117.199997,"NAV2_A":110.599998,"NAV2_S":116.800003,"ADF1_A":284.000000,"ADF2_A":240.000000,"XPDR_A":4608}} Now im trying to figure out how to display the data into a div on my webpage. The old way i was displaying it was this way. Javascript jqXHR = $.getJSON("http://" + location.hostname + "/add_definition?definition_name=RADIO&name=COM1_A&PropertyName=COM ACTIVE FREQUENCY:1&UnitName=MHz&DatumType=FLOAT32", function(dane) {});jqXHR = $.getJSON("http://" + location.hostname + "/get?definition_name=RADIO", function(data){definition_data = data;});if (definition_data == undefined)return;var C1A = document.getElementById("COM1A");C1A.innerHTML = definition_data.COM1_A.toFixed(3); HTML <div class="DISP1" id="COM1A" type="button" name="COM1A" onclick="SETFREQ('com1_swap',1)">XXX.XXX</div> Im not sure how to display the data from the message into my page to display.