Aurquiel ---
2017-03-01 14:02:54 UTC
I have receiving data form an interrupt transfer, i have to receive packets of 204 bytes but after the first package one byte is lost, using a 1024 bytes of transfer.
For example
In one transmission of 1024 bytes i receive packets of 204 bytes inside, so in the first four packets it will fill 816 bytes of the 1024 bytes, the next transmission will have to split the packets 208 bytes in the first transmission ant the rest 8 bytes in the next one followed for the rest, but when they split always i lost one byte in the junction of the two packets.
Code c++ i write:
unsigned char *MPEG2_TS=new unsigned char[1024];
unsigned char *MPEG2_TS_2=new unsigned char[1024];
//It's a return of libusb_interrupt_transfer with the number of bytes that were transferred
int transferred=0;
//It's a return of libusb_interrupt_transfer return 0 if the transfer was successful
int result=0;
//Receiving Transfer
result=libusb_interrupt_transfer (device_handle, //The device handle
0x82, //Endponit 2
MPEG2_TS, //Buffer
1024, //Size of Buffer
&transferred, //Return the number of bytes transferred
0 //waiting time to receive the answer
);
result=libusb_interrupt_transfer (device_handle, //The device handle
0x82, //Endponit 2
MPEG2_TS_2, //Buffer
1024, //Size of Buffer
&transferred, //Return the number of bytes transferred
0 //waiting time to receive the answer
);
write_to_file_2(MPEG2_TS);
write_to_file(MPEG2_TS_2);
I write the code of transmission twice to see what is happening i just receive 2048 bytes and writing to a file, i will use a while loop with one transfer if a resolve the issue.
My device is always sending data through the USB i just wanna catch the packets and join them. i don't know if executing twice the libusb receive interrupt transfer is too slow and my packets are losing
For example
In one transmission of 1024 bytes i receive packets of 204 bytes inside, so in the first four packets it will fill 816 bytes of the 1024 bytes, the next transmission will have to split the packets 208 bytes in the first transmission ant the rest 8 bytes in the next one followed for the rest, but when they split always i lost one byte in the junction of the two packets.
Code c++ i write:
unsigned char *MPEG2_TS=new unsigned char[1024];
unsigned char *MPEG2_TS_2=new unsigned char[1024];
//It's a return of libusb_interrupt_transfer with the number of bytes that were transferred
int transferred=0;
//It's a return of libusb_interrupt_transfer return 0 if the transfer was successful
int result=0;
//Receiving Transfer
result=libusb_interrupt_transfer (device_handle, //The device handle
0x82, //Endponit 2
MPEG2_TS, //Buffer
1024, //Size of Buffer
&transferred, //Return the number of bytes transferred
0 //waiting time to receive the answer
);
result=libusb_interrupt_transfer (device_handle, //The device handle
0x82, //Endponit 2
MPEG2_TS_2, //Buffer
1024, //Size of Buffer
&transferred, //Return the number of bytes transferred
0 //waiting time to receive the answer
);
write_to_file_2(MPEG2_TS);
write_to_file(MPEG2_TS_2);
I write the code of transmission twice to see what is happening i just receive 2048 bytes and writing to a file, i will use a while loop with one transfer if a resolve the issue.
My device is always sending data through the USB i just wanna catch the packets and join them. i don't know if executing twice the libusb receive interrupt transfer is too slow and my packets are losing