2013-12-13 2 views
0

소켓에서 데이터를 읽고 fwrite로 fuile에 쓰기를 원하지만 예외가 계속 발생합니다. 내 코드 :vxworks의 ftp 소켓에서 읽음

MyFile = fopen ("flash:/ngfm.bin","wb"); 
if (MyFile != NULL) { 

    while ((nBytes = read (dataSock, buf, sizeof (buf))) > 0) { 
     ByteCount++; 
     if (ByteCount %10) 
      printf("."); 
     if (ByteCount %100) 
        printf("\n"); 
     fwrite(buf, sizeof(buf), nBytes, MyFile); 
    } 
    printf("%d Bytes written to flash:/ngfm.bin!\n", ByteCount); 
    fclose(MyFile); 
} 
close (dataSock); 

vxworks 내 장치 플래시에 : 존재하고 쓰기입니다! 쉘에서 다음을 수행했습니다 :

JPAX-DP> mf = fopen("flash:/test","w") 
New symbol "mf" added to kernel symbol table. 
mf = 0x26e75e90: value = 636346784 = 0x25ede1a0 
JPAX-DP> fputs("TEST",mf) 
value = 0 = 0x0 
JPAX-DP> fclose(mf) 
value = 0 = 0x0 
JPAX-DP> ls("flash:/") 
flash:/switch_demo_rem.vxs 
flash:/switch_demo_lb_on.vxs 
flash:/switch_demo_lb_off.vxs 
flash:/switch_demo1b.vxs 
flash:/switch_demo1a.vxs 
flash:/switch_demo.vxs 
flash:/sanity.soc 
flash:/rc.soc 
flash:/protection_init.vxs 
flash:/pack_demo.vxs 
flash:/init.vxs 
flash:/config.bcm 
flash:/BCM56440_B0_0.srec 
flash:/BCM56440_A0_1.srec 
flash:/BCM56440_A0_0.srec 
flash:/jpax_msg.log 
flash:/jpax_err.log 
flash:/ngfm.bin 
flash:/test 

답변

1

"buf"가 적절하게 선언되고 충분히 큰지 확인하십시오.