Skip to content

Commit

Permalink
change in read2
Browse files Browse the repository at this point in the history
  • Loading branch information
hpwit committed Sep 14, 2020
1 parent 8213bee commit e2c669a
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 11 deletions.
83 changes: 72 additions & 11 deletions ArtnetESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,75 @@ uint32_t ArtnetESP32::getElaspseTime()

}

uint16_t ArtnetESP32::read3()
{
struct sockaddr_in si_other;
int slen = sizeof(si_other) , len;
long timef=0;

//timef=millis();
incomingUniverse=99;
uint32_t decal=nbPixelsPerUniverse*3+ART_DMX_START;
uint32_t decal2=nbNeededUniverses*decal;
uint8_t * offset;
bool resetframe=true;

er:
timef=millis();
offset=artnetleds1+currentframenumber*decal2;

while(incomingUniverse!=0)
{
if(millis()-timef>1000)
{
Serial.println("Time out fired");
return 0;
}
if ((len = recvfrom(Udp.udp_server, offset, 800, MSG_DONTWAIT, (struct sockaddr *) &si_other, (socklen_t *)&slen)) >0 )//1460
{

incomingUniverse = offset[14] ;
}
}
// if(resetframe==true or frameslues==0)
// {
// current_time=ESP.getCycleCount();
// if(frameslues==0)
// {
// start_time=current_time;
// }
// elaspe[currentframenumber]=(current_time-start_time);
// /*if(elaspe[currentframenumber]/240000<30)
// Serial.printf("frame:%d time:%lu\n",frameslues,elaspe[currentframenumber]/240);*/
// start_time=current_time;
// }
for(int uni=1;uni<nbNeededUniverses;uni++)
{
offset+=decal;
while((len = recvfrom(Udp.udp_server, offset, 800, MSG_DONTWAIT, (struct sockaddr *) &si_other, (socklen_t *)&slen)) <=0)
{
if(millis()-timef>1000)
{
Serial.println("Time out fired");
return 0;
}
}
incomingUniverse = *(offset+14);
if(incomingUniverse!=uni)
{
lostframes++;
resetframe=false;
goto er;
}
}
Udp.flush();
currentframenumber=(currentframenumber+1)%2;
frameslues++;
return 1;
}




uint16_t ArtnetESP32::read2()
{
Expand Down Expand Up @@ -355,26 +424,18 @@ uint16_t ArtnetESP32::read2()
goto er;
}
}




Udp.flush();




currentframenumber=(currentframenumber+1)%2;

frameslues++;

return 1;
}



uint16_t ArtnetESP32::readFrame()
{
uint16_t result;
result=read2();
result=read3();
if(result==1 and artnetAfterFrameHandle)
xTaskNotifyGive(artnetAfterFrameHandle);
return result;
Expand Down
1 change: 1 addition & 0 deletions ArtnetESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class ArtnetESP32
void setBroadcast(byte bc[]);
uint16_t read();
uint16_t read2();
uint16_t read3();
uint16_t read2(TaskHandle_t task);
uint16_t read(TaskHandle_t task);
void printPacketHeader();
Expand Down

0 comments on commit e2c669a

Please sign in to comment.