Subversion Repositories HomeAutomation

Rev

Rev 450 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 450 Rev 1406
Line 4... Line 4...
4
using System.IO;
4
using System.IO;
5
using System.Globalization;
5
using System.Globalization;
6
 
6
 
7
public class HexFile {
7
public class HexFile {
8
    private const ulong USER_RESET_ADDR = 0; //0x1000;  //0x1000 för PIC??
8
    private const ulong USER_RESET_ADDR = 0; //0x1000;  //0x1000 för PIC??
9
    private const ulong BUFFER_SIZE = 5200000;
9
    //private const ulong BUFFER_SIZE = 5200000;
-
 
10
    //private const ulong BUFFER_SIZE = 5;
10
    private const ulong LINE_MAX_SIZE = 1024;
11
    private const ulong LINE_MAX_SIZE = 1024;
11
    private const ulong ERROR_BUFFER_SIZE = 256;
12
    private const ulong ERROR_BUFFER_SIZE = 256;
12
    private const ulong FILE_PATH_SIZE = 256;
13
    private const ulong FILE_PATH_SIZE = 256;
13
   
14
   
14
    private ulong length = 0;
15
    private ulong length = 0;
15
    private ulong addrLower = 0;
16
    private ulong addrLower = 0;
16
    private ulong addrUpper = 0;
17
    private ulong addrUpper = 0;
17
    private string filepath = "";
18
    private string filepath = "";
18
    private bool valid = false;
19
    private bool valid = false;
19
    private byte[] buff = new byte[BUFFER_SIZE];
20
    private byte[] buff=new byte[5200000];
20
   
21
   
21
    public HexFile() { }
22
    public HexFile() { }
22
   
23
   
23
    public bool isValid() { return valid; }
24
    public bool isValid() { return valid; }
24
   
25
   
Line 36... Line 37...
36
        this.addrLower = 0x7FFFFFFF;
37
        this.addrLower = 0x7FFFFFFF;
37
        this.addrUpper = 0;
38
        this.addrUpper = 0;
38
        this.valid = false;
39
        this.valid = false;
39
       
40
       
40
        // Prime the buffer
41
        // Prime the buffer
41
        for (ulong i = 0; i < BUFFER_SIZE; i++) buff[i] = 0xFF;
42
        for (ulong i = 0; i < 5200000; i++) buff[i] = 0xFF;
42
       
43
       
43
       
44
       
44
        // Try opening file
45
        // Try opening file
45
        if (!File.Exists(this.filepath)) {
46
        if (!File.Exists(this.filepath)) {
46
            // The file could not be opened
47
            // The file could not be opened
Line 103... Line 104...
103
   
104
   
104
    public ulong getLength() { return length; }
105
    public ulong getLength() { return length; }
105
   
106
   
106
    public byte getByte(ulong addr)
107
    public byte getByte(ulong addr)
107
    {
108
    {
108
        if (addr>=BUFFER_SIZE) return 0xFF;
109
        if (addr>=5200000) return 0xFF;
109
        return buff[addr];
110
        return buff[addr];
110
    }
111
    }
111
   
112
   
112
}
113
}