Mercurial > ecos
comparison host/tools/ecostest/common/eCosTestDownloadFilter.cpp @ 82:6736c52df507 ecos-sw-2000-04-14
Merge from eCos master repository on 2000-04-14-13:35:46-BST
| author | jlarmour |
|---|---|
| date | Tue, 18 Apr 2000 21:51:55 +0000 |
| parents | 2085233a121a |
| children | 489eb5632bc3 |
comparison
equal
deleted
inserted
replaced
| 81:89fef2181d7d | 82:6736c52df507 |
|---|---|
| 51 //####DESCRIPTIONEND#### | 51 //####DESCRIPTIONEND#### |
| 52 | 52 |
| 53 #include "eCosStd.h" | 53 #include "eCosStd.h" |
| 54 #include "eCosTrace.h" | 54 #include "eCosTrace.h" |
| 55 | 55 |
| 56 #define DL_FILTER_VER "$Id: eCosTestDownloadFilter.cpp,v 1.3 2000/04/07 07:45:09 jlarmour Exp $" | 56 #define DL_FILTER_VER "$Id: eCosTestDownloadFilter.cpp,v 1.4 2000/04/18 21:51:58 jlarmour Exp $" |
| 57 #include "eCosTestDownloadFilter.h" | 57 #include "eCosTestDownloadFilter.h" |
| 58 | 58 |
| 59 CeCosTestDownloadFilter::CeCosTestDownloadFilter(): | 59 CeCosTestDownloadFilter::CeCosTestDownloadFilter(): |
| 60 m_bNullFilter(false), m_bOptSerDebug(false), m_bOptFilterTrace(false), | 60 m_bNullFilter(false), m_bOptSerDebug(false), m_bOptFilterTrace(false), |
| 61 m_nCmdIndex(0), m_bCmdFlag(false), m_bContinueSession(false) | 61 m_nCmdIndex(0), m_bCmdFlag(false), m_bContinueSession(false) |
| 143 d1 += count; | 143 d1 += count; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void | 147 void |
| 148 CeCosTestDownloadFilter::TargetWrite(CeCosTestSerial &pSer, | 148 CeCosTestDownloadFilter::TargetWrite(CeCosSerial &pSer, |
| 149 const unsigned char* buffer, int len) | 149 const unsigned char* buffer, int len) |
| 150 { | 150 { |
| 151 unsigned int __written; | 151 unsigned int __written; |
| 152 | 152 |
| 153 if (m_bOptSerDebug) | 153 if (m_bOptSerDebug) |
| 211 // Based on routines in gdb/remote.c | 211 // Based on routines in gdb/remote.c |
| 212 int | 212 int |
| 213 CeCosTestDownloadFilter::put_binary (unsigned char* buf, int len, | 213 CeCosTestDownloadFilter::put_binary (unsigned char* buf, int len, |
| 214 unsigned long dl_address, | 214 unsigned long dl_address, |
| 215 int packet_size, | 215 int packet_size, |
| 216 CeCosTestSerial& serial) | 216 CeCosSerial& serial) |
| 217 { | 217 { |
| 218 int i; | 218 int i; |
| 219 unsigned char csum; | 219 unsigned char csum; |
| 220 Buffer buf2(packet_size); | 220 Buffer buf2(packet_size); |
| 221 unsigned char ch; | 221 unsigned char ch; |
| 321 // Now expect OK packet from target | 321 // Now expect OK packet from target |
| 322 unsigned char ok_msg[6];// $OK#9a | 322 unsigned char ok_msg[6];// $OK#9a |
| 323 serial.Read(ok_msg, 6, __read); | 323 serial.Read(ok_msg, 6, __read); |
| 324 | 324 |
| 325 // Reply with ACK | 325 // Reply with ACK |
| 326 serial.Write("+", 1, __written); | 326 serial.Write((void*)"+", 1, __written); |
| 327 | 327 |
| 328 // And process next packet. | 328 // And process next packet. |
| 329 resend = 0; | 329 resend = 0; |
| 330 break; | 330 break; |
| 331 | 331 |
| 351 } | 351 } |
| 352 | 352 |
| 353 bool CALLBACK | 353 bool CALLBACK |
| 354 DownloadFilterFunction(void*& pBuf, | 354 DownloadFilterFunction(void*& pBuf, |
| 355 unsigned int& nRead, | 355 unsigned int& nRead, |
| 356 CeCosTestSerial& serial, | 356 CeCosSerial& serial, |
| 357 CeCosTestSocket& socket, | 357 CeCosSocket& socket, |
| 358 void* pParem) | 358 void* pParem) |
| 359 { | 359 { |
| 360 CeCosTestDownloadFilter* p = (CeCosTestDownloadFilter*) pParem; | 360 CeCosTestDownloadFilter* p = (CeCosTestDownloadFilter*) pParem; |
| 361 bool res = false; | 361 bool res = false; |
| 362 | 362 |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool | 376 bool |
| 377 CeCosTestDownloadFilter::FilterFunctionProper(void*& pBuf, | 377 CeCosTestDownloadFilter::FilterFunctionProper(void*& pBuf, |
| 378 unsigned int& nRead, | 378 unsigned int& nRead, |
| 379 CeCosTestSerial& serial, | 379 CeCosSerial& serial, |
| 380 CeCosTestSocket& socket) | 380 CeCosSocket& socket) |
| 381 { | 381 { |
| 382 char* buffer = (char*) pBuf; | 382 char* buffer = (char*) pBuf; |
| 383 | 383 |
| 384 // Assume the worst - don't allow session to continue until a successful | 384 // Assume the worst - don't allow session to continue until a successful |
| 385 // download. | 385 // download. |
| 459 serial.SetBlockingReads(true); | 459 serial.SetBlockingReads(true); |
| 460 serial.Flush(); | 460 serial.Flush(); |
| 461 | 461 |
| 462 // Send + to target, acking whatever packet was pending | 462 // Send + to target, acking whatever packet was pending |
| 463 unsigned int __written = 0; | 463 unsigned int __written = 0; |
| 464 serial.Write("+", 1, __written); | 464 serial.Write((void*)"+", 1, __written); |
| 465 | 465 |
| 466 // Convert to packets and transfer to target. | 466 // Convert to packets and transfer to target. |
| 467 if (put_binary((unsigned char*) buf.Data(), | 467 if (put_binary((unsigned char*) buf.Data(), |
| 468 length, dl_addr, packet_size, serial)) { | 468 length, dl_addr, packet_size, serial)) { |
| 469 // Send detach signal to target | 469 // Send detach signal to target |
| 470 unsigned char ch; | 470 unsigned char ch; |
| 471 unsigned int __read; | 471 unsigned int __read; |
| 472 serial.Write("$D#44", 5, __written); | 472 serial.Write((void*)"$D#44", 5, __written); |
| 473 serial.Read(&ch, 1, __read); | 473 serial.Read(&ch, 1, __read); |
| 474 | 474 |
| 475 // Reply to host marking end of download | 475 // Reply to host marking end of download |
| 476 socket.send("+", 1); | 476 socket.send("+", 1); |
| 477 | 477 |
