Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Ruby to connect with multiple IP Input output interface, Netiom
    primarykey
    data
    text
    <p>I am trying to create an application written in ruby which communicates with multiple input/output interfaces over TCP/IP. The IO interface I am using is called a NETIOM. The interface has 16 digital inputs and 16 digital outputs.</p> <p>How do I:</p> <ul> <li>handle multiple connections? Do I use an array?</li> <li>send a message through single connection and then see its response?</li> <li>'do something' when an input is triggered? I would need to be able to identify which input and interface it was triggered on.</li> </ul> <p>This code works for one Netiom device and is also able to detect inputs being pressed but the code exits after a little while. I have been experimenting with classes and arrays but not getting anywhere.</p> <pre><code>require 'socket' server = TCPServer.open(3012) @socket = server.accept @socket.puts "SEND\r\n" while line = @socket.gets puts line.chop end </code></pre> <p>this code returns:</p> <blockquote> <p>Digital inputs 1-8 : 11111111<br> Digital inputs 9-16: 11111111<br> Digital outputs 1-8 : 00000000<br> Digital outputs 9-16: 00000000 </p> </blockquote> <p>As the client acts in a particular way, I have written up some information about how it works. There is also a link to a pdf manual (take a look at 9th page). <a href="http://www.phaedrusltd.com/Download/NETIOM%20Instructions.pdf" rel="nofollow">http://www.phaedrusltd.com/Download/NETIOM%20Instructions.pdf</a></p> <p>I appreciate any help you can give me and many thanks for your time. </p> <blockquote> <p>When programming the interface you can specify the IP address and port of the server that you want it to communicate, this would be our ruby server. By default, the interface is attempting to connect to the server every 10 seconds until the server finally accepts. Once the server accepts the connection, it should send the message "SEND" and the interface will then return some data with the status of all the inputs and outputs, displayed below. If and when we wanted to close the connection we would send the message "CLOSE".</p> <p>The data that is returned:</p> <p><code>Digital inputs 1-8 : 11111111</code><br> <code>Digital inputs 9-16: 11111111</code><br> <code>Digital outputs 1-8 : 00000000</code><br> <code>Digital outputs 9-16: 00000000</code> </p> <p>If one of the 16 inputs is pressed while there is a connection, it sends the same data as before but it changes that particular input to a '0'</p> <p><code>Digital inputs 1-8 : 01111111</code> // input 1 has been triggered<br> <code>Digital inputs 9-16: 11111111</code><br> <code>Digital outputs 1-8 : 00000000</code><br> <code>Digital outputs 9-16: 00000000</code> </p> <p>When the button is released or let go the file is sent again but now the input is back to normal.</p> <p><code>Digital inputs 1-8 : 11111111</code> // input 1 is back to normal.<br> <code>Digital inputs 9-16: 11111111</code><br> <code>Digital outputs 1-8 : 00000000</code><br> <code>Digital outputs 9-16: 00000000</code> </p> <p>If I want to turn output 8 on, I send A08, and to turn it off I send B08. I can toggle an output by using T08.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload