OpenCores
URL https://opencores.org/ocsvn/adv_debug_sys/adv_debug_sys/trunk

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Software/] [AdvancedWatchpointControl/] [src/] [advancedWatchpointControl/] [ReadRegisterTransaction.java] - Blame information for rev 55

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 nyawn
////////////////////////////////////////////////////////////////
2
//
3
// ReadRegisterTransaction.java
4
//
5
// Copyright (C) 2010 Nathan Yawn 
6
//                    (nyawn@opencores.org)
7
//
8
// This class defines a transaction object which is passed to
9
// the RSP coder in order to perform an RSP 'read' command.
10
//
11
////////////////////////////////////////////////////////////////
12
//
13
// This source file may be used and distributed without
14
// restriction provided that this copyright statement is not
15
// removed from the file and that any derivative work contains
16
// the original copyright notice and the associated disclaimer.
17
// 
18
// This source file is free software; you can redistribute it
19
// and/or modify it under the terms of the GNU General
20
// Public License as published by the Free Software Foundation;
21
// either version 3.0 of the License, or (at your option) any
22
// later version.
23
//
24
// This source is distributed in the hope that it will be
25
// useful, but WITHOUT ANY WARRANTY; without even the implied 
26
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
27
// PURPOSE.  See the GNU Lesser General Public License for more
28
// details.
29
// 
30
// You should have received a copy of the GNU General
31
// Public License along with this source; if not, download it 
32
// from http://www.gnu.org/licenses/gpl.html
33
//
34
////////////////////////////////////////////////////////////////
35 51 nyawn
package advancedWatchpointControl;
36
 
37
public class ReadRegisterTransaction implements TargetTransaction {
38
 
39
        private String packetString = null;
40
        private long dataValueRead = 0;
41
 
42
        public ReadRegisterTransaction(targetDebugRegisterSet.regType reg) {
43
                packetString = new String("p"); // 'p' is read one register
44
                int regAddr = targetDebugRegisterSet.getRegisterAddress(reg);
45
                packetString += Integer.toHexString(regAddr);
46
        }
47
 
48
        @Override
49
        public String getDataToSend() {
50
                return packetString;
51
        }
52
 
53
        @Override
54
        public boolean receivePacket(String pkt) {
55
 
56
                // A register read response has no leading header / char...
57
                // so just parse the number.
58
                long val;
59
                try {
60
                        val = Long.parseLong(pkt, 16);  // data comes back as a hex string
61
                } catch (Exception e) {
62
                        // TODO logMessageGUI("Got invalid read data (size " + pkt.length() + "): " + pkt + ": " + e);
63
                        dataValueRead = 0;
64
                        return false;
65
                }
66
 
67
                dataValueRead = val;
68
                return true;
69
        }
70
 
71
        public long getDataValueRead() {
72
                return dataValueRead;
73
        }
74
 
75
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.