Subversion Repositories Projects

Rev

Rev 1630 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1630 Rev 1688
Line 4... Line 4...
4
 
4
 
5
import dongfang.mkt.comm.FrameQueue;
5
import dongfang.mkt.comm.FrameQueue;
6
import dongfang.mkt.comm.MKConnection;
6
import dongfang.mkt.comm.MKConnection;
7
import dongfang.mkt.comm.serial.RXTXSerialPort;
7
import dongfang.mkt.comm.serial.RXTXSerialPort;
8
import dongfang.mkt.frames.RequestFrame;
8
import dongfang.mkt.frames.RequestFrame;
9
import dongfang.mkt.frames.VariablesRequestFrame;
9
import dongfang.mkt.frames.ReadVariablesRequestFrame;
Line 10... Line 10...
10
import dongfang.mkt.frames.VariablesResponseFrame;
10
import dongfang.mkt.frames.ReadVariablesResponseFrame;
11
 
11
 
12
public class VariablesReader {
12
public class VariablesReader {
13
        private static int[] readVariables(String portIdentifier) throws IOException {
13
        private static int[] readVariables(String portIdentifier) throws IOException {
14
                MKConnection port =  new RXTXSerialPort();
14
                MKConnection port =  new RXTXSerialPort();
15
                port.init(portIdentifier);
15
                port.init(portIdentifier);
Line 16... Line 16...
16
                FrameQueue q = new FrameQueue(port);
16
                FrameQueue q = new FrameQueue(port);
17
                int[] variables = null;
17
                int[] variables = null;
18
               
18
               
19
                VariablesRequestFrame frame = new VariablesRequestFrame(RequestFrame.FC_ADDRESS);
19
                ReadVariablesRequestFrame frame = new ReadVariablesRequestFrame(RequestFrame.FC_ADDRESS);
20
                q.sendRequest(frame);
20
                q.sendRequest(frame);
21
                VariablesResponseFrame r = (VariablesResponseFrame) q.getResponseFor(frame, 5000);
21
                ReadVariablesResponseFrame r = (ReadVariablesResponseFrame) q.getResponseFor(frame, 5000);
22
                if (r == null) {
22
                if (r == null) {
23
                        System.err.println("ERROR. Timeout waiting for response.");
23
                        System.err.println("ERROR. Timeout waiting for response.");