I'm looking at MATLAB (+ Add ons as requried) as part of my dissertaion to model SCADA vulnerabilities, when they use TCP/IP (UDP) etc. This has popped up in my searching. Anybody any ideas if this file is suitable?
Recently I’ve found this script «Real time Data plot from serial port» back from 2010 on MathWorks blogs. Just want to say thanks, it is simple and helpful example. In other words, this not sophisticated code easy to understand and change in any way. To Dimit: you must add terminator (0x0D, 0x0A) after each value of data in your transmission, in basic terminal programs this means to turn on «Send line feeds with carriage return» (or CR=CR+LF). Also could be helpful any “Virtual Serial Port” while debugging without external device.
When I run this code I get the following error. What should I do ?
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> real_time_data_serial at 80
voltage(count) = fscanf(s,'%f');
@Geoffry Akien--I'm not able to duplicate your 2nd error (the one with jtcp_version01), so I'm not sure what to say about that. Your 1st error is really mysterious: a failed jtcp_request_connection() on my machine results in a "connect timed out" error, but the message you get says "Read timed out". I don't know the inner workings of Java well enough to understand why it should be attempting a read operation when you are requesting a connection, so I'm afraid I'm not going to be able to offer you any help here.
I want to use port 502 (I can't change this), but your code formally does not allow the user of ports <1025. I have a device which works just fine using tcpip in the instrument toolbox, but I was hoping to get rid of the dependency by using your code.
Naively changing this limit and using 2012bx64 on W7E I get the following:
>> j = jtcp('REQUEST', '10.10.10.4', 502)
Error using jtcp>jtcp_request_connection (line 293)
Java exception occurred:
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
Error in jtcp (line 230)
jTcpObj = jtcp_request_connection(host,port,timeout,serialize);
...but using the same approach with jtcp_version01 seems to work initially:
>> j = jtcp_version01('REQUEST', '10.10.10.4', 502)
socket: [1x1 java.net.Socket]
inputStream: [1x1 java.net.SocketInputStream]
dataInputStream: [1x1 java.io.DataInputStream]
outputStream: [1x1 java.net.SocketOutputStream]
dataOutputStream: [0 java.io.DataOutputStream]
...but then sending something gives this error:
jtcp_version01('WRITE', j, int8(c))
Error using jtcp_version01>jtcp_write (line 384)
Java exception occurred:
java.net.SocketException: Software caused connection abort: socket
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.DataOutputStream.write(Unknown Source)
Error in jtcp_version01 (line 258)
...although closing the connection seems to work without complaint.