|
TIdServer를 이용하여 전송받은 데이터를 차트에 그리는 프로그램을 만들고있습니다.
코드는 대충 아래와 같습니다. 사정상 풀코드를 올리지는 못하구요ㅜ
설명드리자면
TcpServer의 InputBuffer가 차있으면 거기서 데이터를 읽어오고
데이터 읽은것을 기반으로 Chart에 그리는 형식입니다. 자료가 16bit 형식이라
BytesToShort를 이용하여 변형하였습니다.
그런데 Debug 모드로 한줄씩 돌려보면 문제가 없어보이는데 Run을 하면
Project1.exe raised exception class $C0000005 with message
'access violation at 0x0067429a: read of address 0x00000004'. 라는 메시지가 뜨면서 에러가납니다.
원인이 뭘까요? 도와주세요.
void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
TByteDynArray Buff;
while(AContext->Connection->Connected())
{
if(!AContext->Connection->IOHandler->InputBufferIsEmpty())
{
len = AContext->Connection->IOHandler->InputBuffer->Size;
AContext->Connection->IOHandler->ReadBytes(Buff, len, true );
}
for(int i = 0; i<(int)(len/2); i++)
{
BuffArray = BytesToShort(readTByte, 2*i);
}
UpdateArray();
}
}
void __fastcall TForm1::UpdateArray()
{
Series1->XValues->Value = BuffArray;
Series1->XValues->Count = (int)(len/2);
Series1->XValues->Modified = true;
Series1->Repaint();
}
|