简体   繁体   English

从vxworks中的ftp套接字读取

[英]read from ftp socket in vxworks

I want to read data from a socket and write them to a fuile with fwrite but I keep getting an exception. 我想从套接字读取数据,然后使用fwrite将它们写入fuile,但我一直遇到异常。 My code: 我的代码:

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);

This is on vxworks and my device flash: exists and is writeable! 这在vxworks并且我的设备闪烁:存在并且可写! I did the following on the shell: 我在外壳上执行了以下操作:

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

确保正确地声明了“ buf”并且足够大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM