C - error: unknown type name ‘FILE’ on Zolertia z1 motes
C - error: unknown type name ‘FILE’ on Zolertia z1 motes
我的 z1 mote 充当基站,它直接连接到网关 (pc)。我想在单播中使用此代码保存文本文件中的数据-receiver.c:
//after printing on the screen then store
FILE *f = fopen("clients.txt", "wb");
fwrite(data, sizeof(char), sizeof(data), f);
fclose(f);
但我收到此错误:
unicast-receiver.c: In function ‘receiver’:
unicast-receiver.c:49:1: error: unknown type name ‘FILE’
尽管包含 stdio.h。以前有人遇到过同样的错误吗?我如何解决它?如果没有办法通过 z1 motes 做到这一点,那么还有其他方法来存储数据吗?
这是程序中的内容
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "sys/etimer.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ip/uip-debug.h"
#include "simple-udp.h"
#include "servreg-hack.h"
#include "net/rpl/rpl.h"
#include "dev/cc2420/cc2420.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
msp430
是一个非常受硬件限制的平台,因此不支持完整的 C 标准库功能。特别是在典型的msp430平台上没有硬盘甚至SD卡,所以在软件中也几乎不需要文件系统相关的例程。
如果你查看 msp430-libc
source code,你可以清楚地看到它只支持 printf
函数族。
可以使用xmem
接口在板载闪存上存储数据。该接口在 contiki/core/dev/xmem.h
中定义。使用它很简单:先擦除整个扇区,然后你就可以在那个扇区写入。使用闪存地址作为参数调用 xmem_erase
(您要擦除的扇区中的任何地址),然后调用 xmem_write
传递要写入的缓冲区和写入的闪存地址(起始偏移量)。闪存地址通常从零开始。
也可以使用 Coffee、Contiki 文件系统。
Contiki 提供了一个名为 CFS (Coffee flash system)
的库来抽象闪存和 write/read 以类似文件的方式,Contiki's wiki page
中有一个指南
Zolertia Z1 支持 CFS。
我的 z1 mote 充当基站,它直接连接到网关 (pc)。我想在单播中使用此代码保存文本文件中的数据-receiver.c:
//after printing on the screen then store
FILE *f = fopen("clients.txt", "wb");
fwrite(data, sizeof(char), sizeof(data), f);
fclose(f);
但我收到此错误:
unicast-receiver.c: In function ‘receiver’:
unicast-receiver.c:49:1: error: unknown type name ‘FILE’
尽管包含 stdio.h。以前有人遇到过同样的错误吗?我如何解决它?如果没有办法通过 z1 motes 做到这一点,那么还有其他方法来存储数据吗?
这是程序中的内容
#include "contiki.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "sys/etimer.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/ip/uip-debug.h"
#include "simple-udp.h"
#include "servreg-hack.h"
#include "net/rpl/rpl.h"
#include "dev/cc2420/cc2420.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
msp430
是一个非常受硬件限制的平台,因此不支持完整的 C 标准库功能。特别是在典型的msp430平台上没有硬盘甚至SD卡,所以在软件中也几乎不需要文件系统相关的例程。
如果你查看 msp430-libc
source code,你可以清楚地看到它只支持 printf
函数族。
可以使用xmem
接口在板载闪存上存储数据。该接口在 contiki/core/dev/xmem.h
中定义。使用它很简单:先擦除整个扇区,然后你就可以在那个扇区写入。使用闪存地址作为参数调用 xmem_erase
(您要擦除的扇区中的任何地址),然后调用 xmem_write
传递要写入的缓冲区和写入的闪存地址(起始偏移量)。闪存地址通常从零开始。
也可以使用 Coffee、Contiki 文件系统。
Contiki 提供了一个名为 CFS (Coffee flash system)
的库来抽象闪存和 write/read 以类似文件的方式,Contiki's wiki page
Zolertia Z1 支持 CFS。