08-07-24
long CSGLSDlg::lCom_RcvData( WPARAM wParam, LPARAM lParam )
{
if(Rvd_flag)
{
register int nRcvSize = (int)lParam; // data length
for( int i=0;i<nRcvSize;i++)
{
data1[i]=m_Commthread->g_byRcvBuf[i];
fprintf(_fp1,"%02X\t",data1[i]);
}fprintf(_fp1,"\n");
m_nData++;
UpdateData(FALSE);
}
return 1;
}
08-07-27
long CSGLSDlg::lCom_RcvData( WPARAM wParam, LPARAM lParam )
{if(Rvd_flag)
{
register int nRcvSize = (int)lParam; // data lengthfor( int i=0;i<nRcvSize;i++)
{
data1[i]=m_Commthread->g_byRcvBuf[i];
fprintf(_fp1,"%02X\t",data1[i]);
}if((ByteCount+nRcvSize) >= 25)
{
ByteCount = ByteCount - 25;
}for(i=0;i<nRcvSize;i++)
{
if((ByteFlag==false)&&(data1[i]==250))
{
IdenFlag = true;
StartIden[0] = data1[i];
}
else
{
if(IdenFlag==true)
{
if(data1[i] == 175)
{
StartIden[1] = data1[i];
}
else if(data1[i] == 32)
{
StartIden[2] = data1[i];
}
else if(data1[i] == 170)
{
StartIden[3] = data1[i];
IdenFlag = false;
ByteFlag = true;
}
}
else
{
if(((ByteCount+i)==16)&&(ByteFlag==true))
{
Magneto[0] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[0]);
}
else if(((ByteCount+i)==17)&&(ByteFlag==true))
{
Magneto[1] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[1]);
}
else if(((ByteCount+i)==18)&&(ByteFlag==true))
{
Magneto[2] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[2]);
}
else if(((ByteCount+i)==19)&&(ByteFlag==true))
{
Magneto[3] = data1[i];
// ByteFlag = false;fprintf(_fp2,"%02X\t",Magneto[3]);
}
else if(((ByteCount+i)==20)&&(ByteFlag==true))
{
Magneto[4] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[4]);
}
else if(((ByteCount+i)==21)&&(ByteFlag==true))
{
Magneto[5] = data1[i];
fprintf(_fp2,"%02X\t",Magneto[5]);
ByteFlag = false;
}
} // else
} // else
} // forByteCount = ByteCount + nRcvSize;
fprintf(_fp1,"\n");
fprintf(_fp2,"\n");
m_nData++;
UpdateData(FALSE);
}
return 1;
}
08-08-11
long CSGLSDlg::lCom_RcvData( WPARAM wParam, LPARAM lParam )
{ // check
if(Rvd_flag)
{
register int nRcvSize = (int)lParam; // data lengthfor( int i=0;i<nRcvSize;i++)
{
data1[i]=m_Commthread->g_byRcvBuf[i];
fprintf(_fp1,"%02X\t",data1[i]);
}if((ByteCount+nRcvSize) >= 25)
{
ByteCount = ByteCount - 25;
}for(i=0;i<nRcvSize;i++)
{
if((ByteFlag==false)&&(data1[i]==250))
{
IdenFlag = true;
StartIden[0] = data1[i];
}
else
{
if(IdenFlag==true)
{
if(data1[i] == 175)
{
StartIden[1] = data1[i];
}
else if(data1[i] == 32)
{
StartIden[2] = data1[i];
}
else if(data1[i] == 170)
{
StartIden[3] = data1[i];
IdenFlag = false;
ByteFlag = true;
}
}
else
{
if(((ByteCount+i)==16)&&(ByteFlag==true))
{
Magneto[0] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[0]);temp_m = Magneto[0]>>4;
temp_l = Magneto[0]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
else if(((ByteCount+i)==17)&&(ByteFlag==true))
{
Magneto[1] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[1]);temp_m = Magneto[1]>>4;
temp_l = Magneto[1]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
else if(((ByteCount+i)==18)&&(ByteFlag==true))
{
Magneto[2] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[2]);temp_m = Magneto[2]>>4;
temp_l = Magneto[2]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
else if(((ByteCount+i)==19)&&(ByteFlag==true))
{
Magneto[3] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[3]);temp_m = Magneto[3]>>4;
temp_l = Magneto[3]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
else if(((ByteCount+i)==20)&&(ByteFlag==true))
{
Magneto[4] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[4]);temp_m = Magneto[4]>>4;
temp_l = Magneto[4]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
else if(((ByteCount+i)==21)&&(ByteFlag==true))
{
Magneto[5] = data1[i];
fprintf(_fp2,"%02X\t",Magneto[5]);
ByteFlag = false;temp_m = Magneto[5]>>4;
temp_l = Magneto[5]<<4;
bit_order = temp_m | temp_l;
fprintf(_fp2,"%02x\t",bit_order);
}
} // else
} // else
} // forByteCount = ByteCount + nRcvSize;
fprintf(_fp1,"\n");
fprintf(_fp2,"\n");
m_nData++;
UpdateData(FALSE);
}
return 1;
}
08-08-12
unsigned char bit_more;
unsigned char bit_less;
//unsigned char bit_order;unsigned short int Magneto_x;
unsigned short int Magneto_y;
unsigned short int Magneto_z;
long CSGLSDlg::lCom_RcvData( WPARAM wParam, LPARAM lParam )
{
if(Rvd_flag)
{
register int nRcvSize = (int)lParam; // data lengthfor( int i=0;i<nRcvSize;i++)
{
data1[i]=m_Commthread->g_byRcvBuf[i];
fprintf(_fp1,"%02X\t",data1[i]);
}if((ByteCount+nRcvSize) >= 25)
{
ByteCount = ByteCount - 25;
}for(i=0;i<nRcvSize;i++)
{
if((ByteFlag==false)&&(data1[i]==250))
{
IdenFlag = true;
StartIden[0] = data1[i];
}
else
{
if(IdenFlag==true)
{
if(data1[i] == 175)
{
StartIden[1] = data1[i];
}
else if(data1[i] == 32)
{
StartIden[2] = data1[i];
}
else if(data1[i] == 170)
{
StartIden[3] = data1[i];
IdenFlag = false;
ByteFlag = true;
}
}
else
{
if(((ByteCount+i)==16)&&(ByteFlag==true))
{
Magneto[0] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[0]);bit_more = Magneto[0]>>4;
bit_less = Magneto[0]<<4;
Magneto[0] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[0]);
}
else if(((ByteCount+i)==17)&&(ByteFlag==true))
{
Magneto[1] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[1]);bit_more = Magneto[1]>>4;
bit_less = Magneto[1]<<4;
Magneto[1] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[1]);
}
else if(((ByteCount+i)==18)&&(ByteFlag==true))
{
Magneto[2] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[2]);bit_more = Magneto[2]>>4;
bit_less = Magneto[2]<<4;
Magneto[2] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[2]);
}
else if(((ByteCount+i)==19)&&(ByteFlag==true))
{
Magneto[3] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[3]);bit_more = Magneto[3]>>4;
bit_less = Magneto[3]<<4;
Magneto[3] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[3]);
}
else if(((ByteCount+i)==20)&&(ByteFlag==true))
{
Magneto[4] = data1[i];
// ByteFlag = false;
fprintf(_fp2,"%02X\t",Magneto[4]);bit_more = Magneto[4]>>4;
bit_less = Magneto[4]<<4;
Magneto[4] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[4]);
}
else if(((ByteCount+i)==21)&&(ByteFlag==true))
{
Magneto[5] = data1[i];
fprintf(_fp2,"%02X\t",Magneto[5]);
ByteFlag = false;bit_more = Magneto[5]>>4;
bit_less = Magneto[5]<<4;
Magneto[5] = bit_more | bit_less;
// fprintf(_fp2,"%02x\t",Magneto[5]);
}
} // else
} // else
} // for// fprintf(_fp3,"%02X%\t%02X\t",Magneto[0],Magneto[1]);
// fprintf(_fp3,"%02X%\t%02X\t",Magneto[2],Magneto[3]);
// fprintf(_fp3,"%02X%\t%02X\t",Magneto[4],Magneto[5]);Magneto_x = (Magneto[0]<<8) | Magneto[1];
Magneto_y = (Magneto[2]<<8) | Magneto[3];
Magneto_z = (Magneto[4]<<8) | Magneto[5];fprintf(_fp3,"Magneto_x=%02X\t", Magneto_x);
fprintf(_fp3,"Magneto_y=%02X\t", Magneto_y);
fprintf(_fp3,"Magneto_z=%02X\t", Magneto_z);ByteCount = ByteCount + nRcvSize;
fprintf(_fp1,"\n");
fprintf(_fp2,"\n");
fprintf(_fp3,"\n");
m_nData++;
UpdateData(FALSE);
}
return 1;
}
08-08-16 20:42
- log1.txt가 FA AF 20 AA로 시작하지 않으면, log2.txt에 한 번에 3개씩 (6개가 아니라) 저장된다. 이때 한 주기의 16번(17번째) byte부터 읽는 것이 아니라 무조건 처음에 들어온 데이터로부터 16번(17번째) byte를 읽기 시작한다.
08-08-17 02:22
Debug Assertion Failed!
Program: ...\SGLS.exe
File: wincore.cpp
Line: 958
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the aaplication)
http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/0f287b5f-c1e1-4cd9-a0f0-a418def88edd/
* 변수들의 초기값 설정은 OnInitDialog()에서 한다.
'Hardware > network' 카테고리의 다른 글
UART (범용 비동기화 송수신기) (0) | 2008.07.02 |
---|---|
bluetooth on Mac (0) | 2008.06.17 |
Video Tracking on PC (0) | 2007.08.11 |