Rev 453 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 453 | Rev 457 | ||
|---|---|---|---|
| Line 53... | Line 53... | ||
| 53 | string [] split = null; |
53 | string [] split = null; |
| 54 | split = raw.Split( new Char [] {' '} ); |
54 | split = raw.Split( new Char [] {' '} ); |
| 55 | if ((split.Length >= 3) && (split.Length <= 11)) { |
55 | if ((split.Length >= 3) && (split.Length <= 11)) { |
| 56 | try { |
56 | try { |
| 57 | id = System.Convert.ToUInt32(split[0].Trim(), 16); |
57 | id = System.Convert.ToUInt32(split[0].Trim(), 16); |
| - | 58 | } |
|
| - | 59 | catch { |
|
| - | 60 | Console.WriteLine("overflow 1"); |
|
| 58 | 61 | } |
|
| - | 62 | try { |
|
| 59 | ext = (byte)(System.Convert.ToUInt32(split[1].Trim(), 16)&0xFF); |
63 | ext = (byte)(System.Convert.ToUInt32(split[1].Trim(), 16)&0xFF); |
| - | 64 | } |
|
| - | 65 | catch { |
|
| - | 66 | Console.WriteLine("overflow 2"); |
|
| - | 67 | } |
|
| - | 68 | try { |
|
| 60 | rtr = (byte)(System.Convert.ToUInt32(split[2].Trim(), 16)&0xFF); |
69 | rtr = (byte)(System.Convert.ToUInt32(split[2].Trim(), 16)&0xFF); |
| - | 70 | } |
|
| - | 71 | catch { |
|
| - | 72 | Console.WriteLine("overflow 3"); |
|
| 61 | 73 | } |
|
| - | 74 | try { |
|
| 62 | //testa ext och rtr! |
75 | //testa ext och rtr! |
| 63 | 76 | ||
| 64 | for (int i = 0; i < split.Length-3; i++) { |
77 | for (int i = 0; i < split.Length-3; i++) { |
| 65 | string dummy = split[i+3].Trim(); |
78 | string dummy = split[i+3].Trim(); |
| 66 | if (dummy.Length == 0) break; |
79 | if (dummy.Length == 0) break; |
| 67 | data_length = (byte)((i+1)&0xFF); |
80 | data_length = (byte)((i+1)&0xFF); |
| 68 | //Console.WriteLine("i: " + i + " i+3: " + (i+3) + " split[i+3]: " +split[i+3]); |
81 | //Console.WriteLine("i: " + i + " i+3: " + (i+3) + " split[i+3]: " +split[i+3]); |
| 69 | data[i] = (byte)(System.Convert.ToUInt32(dummy, 16)&0xFF); |
82 | data[i] = (byte)(System.Convert.ToUInt32(dummy, 16)&0xFF); |
| 70 | } |
83 | } |
| 71 | } |
84 | } |
| 72 | catch { |
85 | catch { |
| 73 | Console.WriteLine("overflow "); |
86 | Console.WriteLine("overflow 4"); |
| 74 | } |
87 | } |
| 75 | } |
88 | } |
| 76 | 89 | ||
| 77 | } |
90 | } |
| 78 | - | ||
| 79 | // public CanPacket(byte pktclass, byte type, byte sid, byte rid, byte data_length, byte[] data) { |
- | |
| 80 | // //keep for compability for a while (Downloader.cs) |
- | |
| 81 | // this.id = ((uint)pktclass<<24)|((uint)type<<16)|((uint)sid<<8)|((uint)rid); |
- | |
| 82 | // this.data_length=data_length; |
- | |
| 83 | // ext = 1; |
- | |
| 84 | // rtr = 0; |
- | |
| 85 | // for(int i=0;i<8;i++) this.data[i]=data[i]; |
- | |
| 86 | // } |
- | |
| 87 | - | ||
| 88 | // public CanPacket(byte pktclass, byte type, byte sid, byte rid, byte data_length, byte[] data, byte rtr, byte ext) { |
- | |
| 89 | // this.pktclass=pktclass; |
- | |
| 90 | // this.type=type; |
- | |
| 91 | // this.sid=sid; |
- | |
| 92 | // this.rid=rid; |
- | |
| 93 | // this.data_length=data_length; |
- | |
| 94 | // for(int i=0;i<8;i++) this.data[i]=data[i]; |
- | |
| 95 | // this.ext = (byte)(0x0f & ext); |
- | |
| 96 | // this.rtr = (byte)(0x0f & rtr); |
- | |
| 97 | // } |
- | |
| 98 | 91 | ||
| 99 | public override int GetHashCode() { |
92 | public override int GetHashCode() { |
| 100 | return base.GetHashCode(); |
93 | return base.GetHashCode(); |
| 101 | } |
94 | } |
| 102 | 95 | ||
| Line 111... | Line 104... | ||
| 111 | 104 | ||
| 112 | } |
105 | } |
| 113 | 106 | ||
| 114 | public uint getId() { return this.id; } |
107 | public uint getId() { return this.id; } |
| 115 | public void setId(uint id) { this.id = id; } |
108 | public void setId(uint id) { this.id = id; } |
| 116 |
|
109 | public byte getPktClass(){ return this.pktclass; } |
| 117 | // public uint getType(){ return this.type; } |
- | |
| 118 | // public uint getSid(){ return this.sid; } |
- | |
| 119 | // public uint getRid(){ return this.sid; } |
- | |
| 120 | public void setDataLength(byte datalength){ this.data_length=datalength; } |
110 | public void setDataLength(byte datalength){ this.data_length=datalength; } |
| 121 | public byte getDataLength(){ return this.data_length; } |
111 | public byte getDataLength(){ return this.data_length; } |
| 122 | public byte[] getData(){ return this.data; } |
112 | public byte[] getData(){ return this.data; } |
| 123 | public void setExt(byte ext) { this.ext = ext; } |
113 | public void setExt(byte ext) { this.ext = ext; } |
| 124 | 114 | ||