200 int16_t bytes_recieved=0;
201 uint32_t PacketNum=0;
202 uint32_t MaxPacketNum;
204 static uint32_t FrameCount=0;
206 static uint32_t PacketCount;
209 uint32_t PayloadSize, FramePtr;
217 MaxPacketNum =
ImageSize*
sizeof(uint16_t)/PayloadSize;
218 TempBuf = (uint8_t*)A35FrameBuffer;
224 if( (FrameCount%15) == 0 )
242 while(bytes_recieved <= 0)
244 bytes_recieved=recvfrom(handle->
stream.
cudp,(
char *)bufferin,bsize,0,static_cast<struct sockaddr *>(
nullptr),static_cast<socklen_t *>(
nullptr));
247 if(bytes_recieved==-1)
259 printf(
"Timeout2\n");
265 FrameNum = (bufferin[2]<<8) + bufferin[3];
266 PacketType = bufferin[4];
267 PacketNum = (bufferin[5]<<16) + (bufferin[6]<<8) + bufferin[7];
271 if (PacketNum > PacketCount)
276 printf(
"Lost Packet. PNum=%u, PCount=%u\n" , PacketNum, PacketCount);
282 TempBuf = (uint8_t*)A35FrameBuffer;
283 memset(TempBuf, 0, PayloadSize * (PacketNum-1));
284 TempBuf+=(PayloadSize * (PacketNum-1));
288 FramePtr = (PacketCount-1)*PayloadSize;
289 TempBuf = (uint8_t*)A35FrameBuffer + FramePtr;
290 memset(TempBuf, 0, PayloadSize * (PacketNum-PacketCount));
291 TempBuf+=PayloadSize;
294 PacketCount = PacketNum;
299 if(PacketNum < PacketCount)
301 printf(
"Lost Tail Packet. PNum=%u, PCount=%u\n" , PacketNum, PacketCount);
302 FramePtr = (PacketCount-1)*PayloadSize;
303 TempBuf = (uint8_t*)A35FrameBuffer + FramePtr;
304 memset(TempBuf, 0, PayloadSize * (MaxPacketNum-PacketCount));
322 printf(
"Error recieving frame\n");
327 memcpy(TempBuf, &bufferin[8], bytes_recieved-8);
328 TempBuf += bytes_recieved-8;
338 printf(
"\n\n>>>>> Unknown PackType=%u, PackNum=%u, FrameNum=%u, FrmCnt=%u, \n" , PacketType, PacketNum, FrameNum, FrameCount);
uint16_t bsize
Definition: netperf_listen.cpp:71
#define GIGE_MAX_PACKET
Definition: gige_lib.h:162
int gige_writereg(gige_handle *handle, uint32_t address, uint32_t data)
Write Register.
Definition: gige_lib.cpp:192
ElapsedTime et
Definition: agent_cpu_device_test.cpp:51
void start()
ElapsedTime::start.
Definition: elapsedtime.cpp:203
int32_t cudp
Definition: socketlib.h:120
double lap()
Lap Time.
Definition: elapsedtime.cpp:145
#define GIGE_REG_CCP
Definition: gige_lib.h:126
Definition: elapsedtime.h:62
unsigned int PacketSize
Definition: acq_a35.cpp:51
socket_channel stream
Stream channel.
Definition: gige_lib.h:341