Skip to content

Instantly share code, notes, and snippets.

@thebadger412
Created December 29, 2012 19:58
Show Gist options
  • Save thebadger412/4409028 to your computer and use it in GitHub Desktop.
Save thebadger412/4409028 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
var socket = io.connect('http://YOUR IP HERE');
socket.on('connected', function(data) {
console.log('Connected, this is what I received : ', data);
});
// when you get a receiveSerial event, do this
socket.on('receiveSerial', function (data) {
// look for the textDisplay element in the HTML below:
var element = document.getElementById('modbusDisplay');
console.log(data); //Check the console in chrome tools to see this
$("#serialDisplay").val(data);
// set the stuff inside the element's HTML tags to
// whatever the 'value' property of the received data is:
});
</script>
<h2> SERIAL STRING SEND</h2>
<input id="send" type="submit" value="Send" />
<input id="serialString" value="Enter your Serial string here..." />
<h2> SERIAL STRING RECEIVED:</h2>
<input disabled="disabled" id="serialDisplay" value="Text will appear here.." />
<script>
$("#send").click(function (event) {
event.preventDefault();
var element = document.getElementById('serialString');
socket.emit("sendSerial", element.value);<br /> });
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment