Rev 391 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 391 | Rev 396 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | b_isOpen = false; |
40 | b_isOpen = false; |
41 | } |
41 | } |
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.String.length() > 1) && (RxData.String.at(1) == '#')) |
47 | while ((RxData.str.size() > 1) && (RxData.str.substr(1,1) == string("#"))) |
48 | { |
48 | { |
Line 49... | Line 49... | ||
49 | RxData.String.remove(0,1); |
49 | RxData.str = RxData.str.substr(1, RxData.str.size()); |
50 | } |
50 | } |
51 | 51 | ||
52 | if (ToolBox::check_CRC(RxData.String)) |
52 | if (Parser::check_CRC(RxData.str)) |
53 | { |
53 | { |
54 | RxData.Input = RxData.String.toLatin1().data(); |
54 | RxData.input = (char *)RxData.str.c_str(); |
55 | emit(newData(RxData)); |
55 | emit(newData(RxData)); |
56 | } |
56 | } |
57 | else |
57 | else |
Line 58... | Line 58... | ||
58 | { |
58 | { |
Line 59... | Line 59... | ||
59 | emit(showTerminal(2, RxData.String)); |
59 | emit(showTerminal(2, QString(RxData.str.c_str()))); |
Line 70... | Line 70... | ||
70 | while (RXt[a] != '\0') |
70 | while (RXt[a] != '\0') |
71 | { |
71 | { |
72 | if (RXt[a] == '\r') |
72 | if (RXt[a] == '\r') |
73 | { |
73 | { |
74 | new_Data(QString("")); |
74 | new_Data(QString("")); |
75 | RxData.String = QString(""); |
75 | RxData.str = string(""); |
76 | } |
76 | } |
77 | else |
77 | else |
78 | { |
78 | { |
79 | RxData.String = RxData.String + QString(RXt[a]); |
79 | RxData.str = RxData.str + string(&RXt[a]); |
80 | } |
80 | } |
81 | a++; |
81 | a++; |
82 | } |
82 | } |
83 | } |
83 | } |
Line 122... | Line 122... | ||
122 | case C_TTY : |
122 | case C_TTY : |
123 | { |
123 | { |
124 | TTY->setPort(Address); //Port |
124 | TTY->setPort(Address); //Port |
125 | TTY->open(); |
125 | TTY->open(); |
Line 126... | Line 126... | ||
126 | 126 | ||
Line 127... | Line 127... | ||
127 | ToolBox::Wait(1000); |
127 | ToolBox::wait(1000); |
128 | 128 | ||
129 | if (TTY->isOpen()) |
129 | if (TTY->isOpen()) |
Line 179... | Line 179... | ||
179 | for (int z = 0; z < Len; z++) |
179 | for (int z = 0; z < Len; z++) |
180 | { |
180 | { |
181 | if (Input[z] == '\r') |
181 | if (Input[z] == '\r') |
182 | { |
182 | { |
183 | new_Data(QString("")); |
183 | new_Data(QString("")); |
184 | RxData.String = QString(""); |
184 | RxData.str = string(""); |
185 | } |
185 | } |
186 | else |
186 | else |
187 | { |
187 | { |
188 | RxData.String = RxData.String + Input[z]; |
188 | RxData.str = RxData.str + Input[z].toAscii(); |
189 | } |
189 | } |
190 | } |
190 | } |
191 | } |
191 | } |
Line 192... | Line 192... | ||
192 | 192 | ||
193 | bool cConnection::send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) |
193 | bool cConnection::send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) |
194 | { |
194 | { |
195 | if (b_isOpen) |
195 | if (b_isOpen) |
196 | { |
196 | { |
197 | QByteArray Temp; |
197 | QByteArray Temp; |
Line 198... | Line 198... | ||
198 | QString TX_Data; |
198 | string TX_Data; |
199 | 199 | ||
200 | if (CMD != '#') |
200 | if (CMD != '#') |
Line -... | Line 201... | ||
- | 201 | { |
|
201 | { |
202 | TX_Data = Parser::encode64(Data, Length); |
202 | TX_Data = ToolBox::Encode64(Data, Length); |
203 | |
Line 203... | Line 204... | ||
203 | 204 | char addr = 'a' + Address; |
|
Line 204... | Line 205... | ||
204 | TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
205 | TX_Data = string("#") + (string(&addr)) + string(&CMD) + TX_Data; |
205 | TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
206 | TX_Data = Parser::add_CRC(TX_Data) + '\r'; |
206 | 207 | ||
207 | Temp = QByteArray(TX_Data.toUtf8()); |
208 | Temp = QByteArray(TX_Data.c_str()); |
Line 232... | Line 233... | ||
232 | TcpSocket->write(Temp); |
233 | TcpSocket->write(Temp); |
233 | } |
234 | } |
234 | break; |
235 | break; |
235 | } |
236 | } |
Line 236... | Line 237... | ||
236 | 237 | ||
237 | emit(showTerminal(3, TX_Data)); |
238 | emit(showTerminal(3, QString(TX_Data.c_str()))); |
238 | } |
239 | } |
239 | return true; |
240 | return true; |
Line 240... | Line 241... | ||
240 | } |
241 | } |