hello!
i'm using C6416 board, and try to read a file to the buffer in my
program. i use the fopen func, but the value of the *fp is always NULL.
i've been looking for the reason, and find that the size of heap(if too
small) maybe the key.however,when i try to read a 9 byte file, the pointer is
still NULL(T_T),so i have no idea about the possible reason for my failure.my
lines:
FILE *pRx
pRx = fopen("oooo.txt","r");
if(pRx==NULL)
{
fclose(pRx);
LOG_printf(&trace,"error");
}
oooo.txt contains only 9 strings, and in its file property,the size is 9
bytes.
cathy
_____________________________________
fopen can't even open the 9 byte size files
Started by ●August 19, 2010
Reply by ●August 19, 20102010-08-19
Cathy,
On first look at the code, I expect the problem is the file (on your PC) is not being
found. Have you tried displaying the errno variable and decoding its' value?
I expect the following needs to be looked at:
--the C:\ drive needs to be 'share-able'
--the exact path to the sub directory containing the file needs to be specified,
probably in the 'open' statement.
R. Williams
---------- Original Message -----------
From: f...@163.com
To: c...
Sent: Thu, 19 Aug 2010 06:57:07 -0400
Subject: [c6x] fopen can't even open the 9 byte size files
> hello!
> i'm using C6416 board, and try to read a file to the buffer in my
> program. i use the fopen func, but the value of the *fp is always
> NULL. i've been looking for the reason, and find that the size of
> heap(if too small) maybe the key.however,when i try to read a 9 byte
> file, the pointer is still NULL(T_T),so i have no idea about the
> possible reason for my failure.my lines: FILE *pRx pRx > fopen("oooo.txt","r"); if(pRx==NULL) { fclose(pRx);
> LOG_printf(&trace,"error"); } oooo.txt contains only 9 strings, and
> in its file property,the size is 9 bytes.
>
> cathy
------- End of Original Message -------
_____________________________________
On first look at the code, I expect the problem is the file (on your PC) is not being
found. Have you tried displaying the errno variable and decoding its' value?
I expect the following needs to be looked at:
--the C:\ drive needs to be 'share-able'
--the exact path to the sub directory containing the file needs to be specified,
probably in the 'open' statement.
R. Williams
---------- Original Message -----------
From: f...@163.com
To: c...
Sent: Thu, 19 Aug 2010 06:57:07 -0400
Subject: [c6x] fopen can't even open the 9 byte size files
> hello!
> i'm using C6416 board, and try to read a file to the buffer in my
> program. i use the fopen func, but the value of the *fp is always
> NULL. i've been looking for the reason, and find that the size of
> heap(if too small) maybe the key.however,when i try to read a 9 byte
> file, the pointer is still NULL(T_T),so i have no idea about the
> possible reason for my failure.my lines: FILE *pRx pRx > fopen("oooo.txt","r"); if(pRx==NULL) { fclose(pRx);
> LOG_printf(&trace,"error"); } oooo.txt contains only 9 strings, and
> in its file property,the size is 9 bytes.
>
> cathy
------- End of Original Message -------
_____________________________________
Reply by ●August 20, 20102010-08-20
Cathy,
On 8/19/2010 5:57 AM, f...@163.com wrote:
>
> hello!
> i'm using C6416 board, and try to read a file to the buffer in my
> program. i use the fopen func, but the value of the *fp is always
> NULL. i've been looking for the reason, and find that the size of
> heap(if too small) maybe the key.however,when i try to read a 9 byte
> file, the pointer is still NULL(T_T),so i have no idea about the
> possible reason for my failure.my lines:
>
You probably have a 'path' problem - the file cannot be found.
Modify your test case with a write option and a few bytes of data.
1. I suspect that you will not have trouble getting past 'fopen'.
2. You might be surprised where the file is created [you might have to
seach for it].
3. Once you pass the 'write test', copy "oooo.txt" to that directory and
rerun the test.
mikedunn
>
> FILE *pRx
> pRx = fopen("oooo.txt","r");
> if(pRx==NULL)
> {
> fclose(pRx);
> LOG_printf(&trace,"error");
> }
> oooo.txt contains only 9 strings, and in its file property,the size is
> 9 bytes.
>
> cathy
On 8/19/2010 5:57 AM, f...@163.com wrote:
>
> hello!
> i'm using C6416 board, and try to read a file to the buffer in my
> program. i use the fopen func, but the value of the *fp is always
> NULL. i've been looking for the reason, and find that the size of
> heap(if too small) maybe the key.however,when i try to read a 9 byte
> file, the pointer is still NULL(T_T),so i have no idea about the
> possible reason for my failure.my lines:
>
You probably have a 'path' problem - the file cannot be found.
Modify your test case with a write option and a few bytes of data.
1. I suspect that you will not have trouble getting past 'fopen'.
2. You might be surprised where the file is created [you might have to
seach for it].
3. Once you pass the 'write test', copy "oooo.txt" to that directory and
rerun the test.
mikedunn
>
> FILE *pRx
> pRx = fopen("oooo.txt","r");
> if(pRx==NULL)
> {
> fclose(pRx);
> LOG_printf(&trace,"error");
> }
> oooo.txt contains only 9 strings, and in its file property,the size is
> 9 bytes.
>
> cathy
Reply by ●August 21, 20102010-08-21
oh,R. Williams and mikedunn
thx for both of you!
the problem is solved
it is the path!
in the CCS3.1, i must write out the exact path,at first i thought it may automatically find the file in the folder of the project, but the test proves that i should specify the path clearly.
---------------previous----------------
hello!
> i'm using C6416 board, and try to read a file to the buffer in my program. i use the fopen func, but the value of the *fp is always NULL. i've been looking for the reason, and find that the size of heap(if too small) maybe the key.however,when i try to read a 9 byte file, the pointer is still NULL(T_T),so i have no idea about the possible reason for my failure.my lines:
> FILE *pRx
> pRx = fopen("oooo.txt","r");
> if(pRx==NULL)
> {
> fclose(pRx);
> LOG_printf(&trace,"error");
> }
>oooo.txt contains only 9 strings, and in its file property,the size is 9 bytes.
>
>cathy
>
>_____________________________________
_____________________________________
thx for both of you!
the problem is solved
it is the path!
in the CCS3.1, i must write out the exact path,at first i thought it may automatically find the file in the folder of the project, but the test proves that i should specify the path clearly.
---------------previous----------------
hello!
> i'm using C6416 board, and try to read a file to the buffer in my program. i use the fopen func, but the value of the *fp is always NULL. i've been looking for the reason, and find that the size of heap(if too small) maybe the key.however,when i try to read a 9 byte file, the pointer is still NULL(T_T),so i have no idea about the possible reason for my failure.my lines:
> FILE *pRx
> pRx = fopen("oooo.txt","r");
> if(pRx==NULL)
> {
> fclose(pRx);
> LOG_printf(&trace,"error");
> }
>oooo.txt contains only 9 strings, and in its file property,the size is 9 bytes.
>
>cathy
>
>_____________________________________
_____________________________________