DSPRelated.com
Forums

RTDX target to host frame transfer Program runtime bug

Started by "H.264encoderondm642" February 7, 2007
I have small test program for target to host file transfer on SIMULATOR of CCS. which copies frame one after other to host by RTDX. As frame size QCIF will be 38016, 44 * 864 = 38016. so 864 bytes are transferred at a time from any one frame. This continues in loop.

I have runtime problem at line====>

if ( !RTDX_write( &ochan, (frame_yuv + offset_internal+ offset), 864*sizeof(unsigned char) ) )
{
fprintf(stderr, "\nError: RTDX_write() failed!\n");
abort();
}

At these line i could not able to judge weather condition becomes false or true. As CCS exits without any message inside braces.

I want to know weather RTDX_write line syntax is correct or not.... i am not able to figure out.

Also what host buffer size should be set if i wants to send 38016 bytes at a time. I tried to set it to 38020 bytes wih 4 buffers in number but error comes to set larger buffer size!

Regards,
Nilesh

* Target-To-Host Test:
*____________________________________________________________________
* - Sends 864 bytes, at a time via RTDX_write(). One frame has 38016 bytes. So inner loop has limit of 44. as 44 * 864 = 38016.
* - Uses ONE output channel.
*
* - Tests Data transmission from target to host at the User layer.
* - This is the module to be run on the TARGET.
*************************************************************************/
#include /* fprintf(), puts() */
#include /* abort() */
#include /* RTDX */
#include "target.h" /* TARGET_INITIALIZE() */
/* Declare and initialize an output channel called "ochan" */
RTDX_CreateOutputChannel(ochan);
#define NUMBER_MESSAGES 38016
void main( void )
{
unsigned int data,i,j,offset=0,offset_internal=0;
char filename[60] = "D:/a_nilesh/Sample RTDX/Debug/foreman_part_qcif.yuv";
FILE *FP;
unsigned char frame_yuv[38016];
long bytes=0;
if ( ( FP = fopen( filename, "rb" ) ) == NULL )
{
fprintf(stdout, "Error opening source file %s", filename);
exit(1);
}
if ( (fseek(FP, 0, SEEK_END))!=0)
{
fprintf(stderr, "\nError using fseek().");
exit(1);
}
bytes=ftell(FP); /*get file size which will be muliple of 38016 always*/
fseek(FP, 0, SEEK_SET);

/* Target Specific Initialization */
TARGET_INITIALIZE();

/* Enable the output channel, "ochan" */
RTDX_enableOutput(&ochan);
while(1) /*outermost loop to copy frames one by one of size 38016 bytes*/
{
if (offset >= bytes)
break;
for (i=0; i< 38016; i++) /* copy 1 frame to internal memory*/
{
frame_yuv[i] = fgetc(FP);
}
offset_internal = 0; /*initialise at each new frame*/
for(j=0; j<44; j++) /*loop to send 864 bytes block at a time one by one*/
{
printf("Sending 864 Messages to Host...\n");
/* Send the data to the host */
if ( !RTDX_write( &ochan, (frame_yuv + offset_internal+ offset), 864*sizeof (unsigned char) ) )
{
fprintf(stderr, "\nError: RTDX_write() failed!\n");
abort();
}

/* Wait for Target-to-Host transfer to complete */
while ( RTDX_writing != NULL )
{
#if RTDX_POLLING_IMPLEMENTATION
/* If polling implementation of RTDX... */
/* ...call RTDX_Poll to do data transfer */
RTDX_Poll();
#endif
}
offset_internal = offset_internal + 864;
}
offset= offset + 38016;
fprintf(stdout, "38016 Values were sent to the host\n");
}

fclose ( FP );
/* Disable the output channel, "ochan" */
RTDX_disableOutput(&ochan);

puts("\nTest Completed!");
}
Hello Sir,
I have resolved this problem. Actually for RTDX one has to enable it and use target board. On simulator it hangs(could not understand why after enabling RTDX also or correct library inclusion). But on board it works nicely.

Now other thing comes into picture here. By some trial and error method i tried to send block of data at a time for various sizes. With host buffer by default = 1024 bytes and 4 in number.

As i reached 1012 byte size for block of data threshold reaches and data transferred correctly. But beyond that target could not do transfer to host.

ie it gets hanged at line

while ( RTDX_writing != NULL )

or it runns indefinitely.

I could not understand why 1012 only and not 1024 is limit? I read somewhere that there is bug in ccs for last 1 byte to be transffered so as to increase buffer size by 1 byte more.

But then here it is 12 bytes....

Regards,
Nilesh
Jeff Brower wrote: Nilesh-

> I have small test program for target to host file transfer on SIMULATOR of
> CCS. which copies frame one after other to host by RTDX. As frame size QCIF
> will be 38016, 44 * 864 = 38016. so 864 bytes are transferred at a time
> from any one frame. This continues in loop.
>
> I have runtime problem at line====> if ( !RTDX_write( &ochan, (frame_yuv + offset_internal+ offset), 864*sizeof(unsigned char) ) )
> {
> fprintf(stderr, "\nError: RTDX_write() failed!\n"); <-- bp
> abort();
> }
> At these line i could not able to judge weather condition becomes false
> or true. As CCS exits without any message inside braces.

Try inserting a CCS breakpoint at "bp", before attempting to print. fprintf() may
also use RTDX, so if there is some basic problem, then you will never see the
fprintf() result.

-Jeff

---------------------------------
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
Nilesh-

> I have small test program for target to host file transfer on SIMULATOR of
> CCS. which copies frame one after other to host by RTDX. As frame size QCIF
> will be 38016, 44 * 864 = 38016. so 864 bytes are transferred at a time
> from any one frame. This continues in loop.
>
> I have runtime problem at line====> if ( !RTDX_write( &ochan, (frame_yuv + offset_internal+ offset), 864*sizeof(unsigned char) ) )
> {
> fprintf(stderr, "\nError: RTDX_write() failed!\n"); <-- bp
> abort();
> }
> At these line i could not able to judge weather condition becomes false
> or true. As CCS exits without any message inside braces.

Try inserting a CCS breakpoint at "bp", before attempting to print. fprintf() may
also use RTDX, so if there is some basic problem, then you will never see the
fprintf() result.

-Jeff
Nilesh-

> I have resolved this problem. Actually for RTDX one has to enable
> it and use target board. On simulator it hangs(could
> not understand why after enabling RTDX also or correct library
> inclusion). But on board it works nicely.

Sounds like good progress. You're almost not a newbie any more :-)

> Now other thing comes into picture here. By some trial and error
> method i tried to send block of data at a time for
> various sizes. With host buffer by default = 1024 bytes and 4 in number.
>
> As i reached 1012 byte size for block of data threshold reaches and
> data transferred correctly. But beyond that target
> could not do transfer to host.
>
> ie it gets hanged at line
>
> while ( RTDX_writing != NULL )
>
> or it runns indefinitely.
>
> I could not understand why 1012 only and not 1024 is limit? I read somewhere that there is bug in ccs for last 1 byte
> to be transffered so as to increase buffer size by 1 byte more.
>
> But then here it is 12 bytes....

I'm not sure about this. But I would also say I'm not surprised, as RTDX does have some strangenesses. You may have
to just assume that last 3 words (12 bytes) is not reliable and discard those. Maybe someone else can comment on
this...

-Jeff
> Jeff Brower wrote:
>
> Nilesh-
>
>> I have small test program for target to host file transfer on SIMULATOR of
>> CCS. which copies frame one after other to host by RTDX. As frame size QCIF
>> will be 38016, 44 * 864 = 38016. so 864 bytes are transferred at a time
>> from any one frame. This continues in loop.
>>
>> I have runtime problem at line====>
>>
>> if ( !RTDX_write( &ochan, (frame_yuv + offset_internal+ offset), 864*sizeof(unsigned char) ) )
>> {
>> fprintf(stderr, "\nError: RTDX_write() failed!\n"); <-- bp
>> abort();
>> }
>> At these line i could not able to judge weather condition becomes false
>> or true. As CCS exits without any message inside braces.
>
> Try inserting a CCS breakpoint at "bp", before attempting to print. fprintf() may
> also use RTDX, so if there is some basic problem, then you will never see the
> fprintf() result.
>
> -Jeff