KIM HyoengJun
/
mbed_fota_fan_control
Fan Control Demo
Fork of mbed_fota by
Diff: ext_fota/SerialManager.cpp
- Revision:
- 5:e11b23f9aacc
- Parent:
- 3:1e70387e1337
- Child:
- 6:8dd20294b2aa
diff -r 60be78a172c2 -r e11b23f9aacc ext_fota/SerialManager.cpp --- a/ext_fota/SerialManager.cpp Wed Jun 24 08:50:07 2015 +0000 +++ b/ext_fota/SerialManager.cpp Mon Jul 13 06:32:05 2015 +0000 @@ -38,14 +38,14 @@ void SerialManager::PrintSerialManager(void) { if(print_flag == 1) - hostpc->printf("SerialManager Start!!\n"); + hostpc->printf("\nSerialManager Start!!\n"); } int SerialManager::SendToSerial(uint8_t *data,unsigned short size) { int cnt = 0; if(print_flag == 1) - hostpc->printf("send size = %hu\n",size); + hostpc->printf("\n>>> send size = %hu\n",size); for(int i=0; i < size; i++) { @@ -65,7 +65,6 @@ { int ret = -1; unsigned char tmp; - if(device->readable()) { tmp = device->getc(); @@ -78,6 +77,7 @@ wDataLength = 0; wReceivePos = 0; bHdrBytesRead = 0; + memset(bReceiveElementArr,0,512); bReceiveElementArr[wReceivePos] = tmp; wReceivePos++; @@ -151,7 +151,7 @@ break; default: if(print_flag == 1) - hostpc->printf("ERROR STRAGE STATE\n"); + hostpc->printf("\nERROR STRAGE STATE R+%02X \n",tmp); break; } } @@ -159,4 +159,43 @@ return ret; } +void SerialManager::ReceiveToSerialTest(void) +{ + unsigned char tmp; + int pos = 0; + char buff[128]; + memset(buff,'K',127); + buff[127] = '\0'; + hostpc->printf("\n pos = %d FIRST <%s> \n",pos,buff); + tmp = device->getc(); + tmp = device->getc(); + tmp = device->getc(); + tmp = device->getc(); + tmp = device->getc(); + while(1) + { + if(device->readable()) + { + tmp = device->getc(); + hostpc->printf("%d ==> 0x%X\n",pos,tmp); + buff[pos] = tmp; + pos++; + if( pos == 128 ){ + pos = 0; + memset(buff,'Z',127); + buff[127] = '\0'; + } + if( pos%16 == 0 ){ + hostpc->printf("\n pos = %d ERROR <%s> \n",pos,buff); + if(device->writeable()){ + hostpc->printf("writeable!!\n"); + device->putc(0x80); + device->putc(0x44); + } + } + } + + } +} + }//namespace