Rev 440 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 440 | Rev 449 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | 42 | ||
43 | void cConnection::new_Data(QString Data) |
43 | void cConnection::new_Data(QString Data) |
44 | { |
44 | { |
Line 45... | Line 45... | ||
45 | //Data = Data; |
45 | //Data = Data; |
46 | 46 | ||
47 | while ((RxData.str.size() > 1) && (RxData.str.substr(1,1) == string("#"))) |
47 | /* while ((RxData.str.size() > 1) && (RxData.str.substr(1,1) == string("#"))) |
48 | { |
48 | { |
Line 49... | Line 49... | ||
49 | RxData.str = RxData.str.substr(1, RxData.str.size()); |
49 | RxData.str = RxData.str.substr(1, RxData.str.size()); |
Line 56... | Line 56... | ||
56 | } |
56 | } |
57 | else |
57 | else |
58 | { |
58 | { |
59 | emit(showTerminal(2, QString(RxData.str.c_str()))); |
59 | emit(showTerminal(2, QString(RxData.str.c_str()))); |
60 | } |
60 | } |
61 | 61 | */ |
|
62 | } |
62 | } |
Line 63... | Line 63... | ||
63 | 63 | ||
64 | void cConnection::slot_newDataReceived(const QByteArray &dataReceived) |
64 | void cConnection::slot_newDataReceived(const QByteArray &dataReceived) |
- | 65 | { |
|
65 | { |
66 | /* |
66 | const char *RXt; |
67 | const char *RXt; |
67 | RXt = dataReceived.data(); |
68 | RXt = dataReceived.data(); |
Line 68... | Line 69... | ||
68 | int a = 0; |
69 | int a = 0; |
Line 78... | Line 79... | ||
78 | { |
79 | { |
79 | RxData.str = RxData.str + string(&RXt[a]); |
80 | RxData.str = RxData.str + string(&RXt[a]); |
80 | } |
81 | } |
81 | a++; |
82 | a++; |
82 | } |
83 | } |
- | 84 | */ |
|
83 | } |
85 | } |
Line 84... | Line 86... | ||
84 | 86 | ||
85 | bool cConnection::isOpen() |
87 | bool cConnection::isOpen() |
86 | { |
88 | { |
Line 179... | Line 181... | ||
179 | for (int z = 0; z < Len; z++) |
181 | for (int z = 0; z < Len; z++) |
180 | { |
182 | { |
181 | if (Input[z] == '\r') |
183 | if (Input[z] == '\r') |
182 | { |
184 | { |
183 | new_Data(QString("")); |
185 | new_Data(QString("")); |
184 | RxData.str = string(""); |
186 | //RxData.str = string(""); |
185 | } |
187 | } |
186 | else |
188 | else |
187 | { |
189 | { |
188 | RxData.str = RxData.str + Input[z].toAscii(); |
190 | //RxData.str = RxData.str + Input[z].toAscii(); |
189 | } |
191 | } |
190 | } |
192 | } |
191 | } |
193 | } |
Line 192... | Line 194... | ||
192 | 194 | ||
193 | bool cConnection::send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) |
195 | bool cConnection::send_Cmd(char CMD, int Address, char Data[MAX_DATA_SIZE],unsigned int Length, bool Resend) |
194 | { |
196 | { |
195 | if (b_isOpen) |
197 | if (b_isOpen) //is_connected() |
196 | { |
198 | { |
197 | QByteArray Temp; |
- | |
198 | string TX_Data; |
199 | QByteArray Temp; |
199 | 200 | /* |
|
200 | if (CMD != '#') |
201 | if (CMD != '#') |
201 | { |
202 | { |
202 | TX_Data = Parser::encode64(Data, Length); |
- | |
- | 203 | TX_Data = Parser::encode64(Data, Length); |
|
203 | 204 | string TX_Data; |
|
204 | char addr = 'a' + Address; |
205 | char addr = 'a' + Address; |
205 | TX_Data = string("#") + (string(&addr)) + string(&CMD) + TX_Data; |
206 | TX_Data = string("#") + (string(&addr)) + string(&CMD) + TX_Data; |
Line 206... | Line 207... | ||
206 | TX_Data = Parser::add_CRC(TX_Data) + '\r'; |
207 | TX_Data = Parser::add_CRC(TX_Data) + '\r'; |
Line 210... | Line 211... | ||
210 | if (Resend) |
211 | if (Resend) |
211 | { |
212 | { |
212 | o_Timer->start(2000); |
213 | o_Timer->start(2000); |
213 | s_ReSend = Temp; |
214 | s_ReSend = Temp; |
214 | } |
215 | } |
- | 216 | emit(showTerminal(3, QString(TX_Data.c_str()))); |
|
215 | } |
217 | } |
216 | else |
218 | else |
217 | { |
219 | { |
218 | for (unsigned int a = 0; a < Length; a++) |
220 | for (unsigned int a = 0; a < Length; a++) |
219 | { |
221 | { |
220 | Temp[a] = Data[a]; |
222 | Temp[a] = Data[a]; |
221 | } |
223 | } |
222 | } |
224 | } |
223 | 225 | */ |
|
224 | switch(i_Type) |
226 | switch(i_Type) |
225 | { |
227 | { |
226 | case C_TTY : |
228 | case C_TTY : |
227 | { |
229 | { |
228 | TTY->sendData(Temp); |
230 | TTY->sendData(Temp); |
Line 232... | Line 234... | ||
232 | { |
234 | { |
233 | TcpSocket->write(Temp); |
235 | TcpSocket->write(Temp); |
234 | } |
236 | } |
235 | break; |
237 | break; |
236 | } |
238 | } |
237 | - | ||
238 | emit(showTerminal(3, QString(TX_Data.c_str()))); |
- | |
239 | } |
239 | } |
240 | return true; |
240 | return true; |
241 | } |
241 | } |
Line 242... | Line 242... | ||
242 | 242 |