i used following code on RP to send trace data with ~20Hz to Desktop Computer.
Code: Select all
char strges[array_size*9+500];
sprintf(strges, "Some Text information #StartOfTrace");
for(int g=0; g<array_size; ++g){
sprintf(buffer, "%f ", buff[g]);
strcat(strges, buffer);
}
strcat(strges, "#EndOfTrace #End\n");
/* send data to socket * /
write(sockfd, strges, strlen(strges));
But the loop isn't really nice coded, so for 16000 Samples it takes 5 seconds, only for the loop.
So i switched to use memcpy(), which is really fast, but i got problems by decoding the code on desktop, because the size of the strings vary.
Code: Select all
int anzahlzeichen = 150;
char tosend[array_size*sizeof(float)+200];
sprintf(tosend, "Some Text information #StartOfTrace");
memcpy(tosend+anzahlzeichen, buff, array_size*sizeof(float));
char tempstr[50];
sprintf(tempstr, "#EndOfTrace #End\n");
memcpy(tosend+anzahlzeichen+array_size*sizeof(float), tempstr, strlen(tempstr));
tosend[anzahlzeichen+array_size*sizeof(float)+strlen(tempstr)]='\0';
write(sockfd, tosend, anzahlzeichen+array_size*sizeof(float)+strlen(tempstr));
Is there a source code from it? i only found the github page ( https://github.com/RedPitaya/RedPitaya/ ... cpi-server ), but there is only the bin file.
OR: Can someone explain me, how to send large data over TCP?
Thanks in advance
GrafZahl