微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > CC3220S SDK中关于FS.h中的fs_Open flags是什么意思?

CC3220S SDK中关于FS.h中的fs_Open flags是什么意思?

时间:10-02 整理:3721RD 点击:
/*
  fs_Open flags
  --------------
*/

/* mode */
#define     SL_FS_CREATE                           ((_u32)0x1<<(SL_NUM_OF_MAXSIZE_BIT+SL_NUM_OF_FLAGS_BIT))
#define     SL_FS_WRITE                            ((_u32)0x2<<(SL_NUM_OF_MAXSIZE_BIT+SL_NUM_OF_FLAGS_BIT))
#define     SL_FS_OVERWRITE                        ((_u32)0x4<<(SL_NUM_OF_MAXSIZE_BIT+SL_NUM_OF_FLAGS_BIT))
#define     SL_FS_READ                             ((_u32)0x8<<(SL_NUM_OF_MAXSIZE_BIT+SL_NUM_OF_FLAGS_BIT))
/* creation flags */
#define     SL_FS_CREATE_FAILSAFE                  ((_u32)0x1<<SL_NUM_OF_MAXSIZE_BIT)         /* Fail safe */
#define     SL_FS_CREATE_SECURE                    ((_u32)0x2<<SL_NUM_OF_MAXSIZE_BIT)         /* SECURE */
#define     SL_FS_CREATE_NOSIGNATURE               ((_u32)0x4<<SL_NUM_OF_MAXSIZE_BIT)         /* Relevant to secure file only  */
#define     SL_FS_CREATE_STATIC_TOKEN              ((_u32)0x8<<SL_NUM_OF_MAXSIZE_BIT)         /* Relevant to secure file only */
#define     SL_FS_CREATE_VENDOR_TOKEN              ((_u32)0x10<<SL_NUM_OF_MAXSIZE_BIT)        /* Relevant to secure file only */
#define     SL_FS_CREATE_PUBLIC_WRITE              ((_u32)0x20<<SL_NUM_OF_MAXSIZE_BIT)        /* Relevant to secure file only, the file can be opened for write without Token */
#define     SL_FS_CREATE_PUBLIC_READ               ((_u32)0x40<<SL_NUM_OF_MAXSIZE_BIT)        /* Relevant to secure file only, the file can be opened for read without Token  */

#define     SL_FS_CREATE_MAX_SIZE( MaxFileSize )           ((((_u32)MaxFileSize + 255) / 256 ) & SL_FS_OPEN_MAXSIZE_BIT_MASK )

/* write flags */
#define    SL_FS_WRITE_MUST_COMMIT                  ((_u32)0x80<<SL_NUM_OF_MAXSIZE_BIT)        /* The file is locked for changes */
#define    SL_FS_WRITE_BUNDLE_FILE                  ((_u32)0x100<<SL_NUM_OF_MAXSIZE_BIT)       /* The file is locked for changes as part of Bundle */
#define    SL_FS_WRITE_ENCRYPTED                    ((_u32)0x200<<SL_NUM_OF_MAXSIZE_BIT)       /* This indicates the start of a secured content write session */

什么意思   为什么这段带么执行后,

       DeviceFileHandle =  sl_FsOpen(unsigned char *)DeviceFileName,
                                        SL_FS_READ,
                                        &MasterToken);

       Offset = 0;
       RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));

       RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

打不开

char*           DeviceFileName = "MyFile.txt";
       unsigned long   MaxSize = 63 * 1024; //62.5K is max file size
       long            DeviceFileHandle = -1;
       _i32            RetVal;        //negative retval is an error
       unsigned long   Offset = 0;
       unsigned char   InputBuffer[100];
	   _u32 MasterToken = 0;

       // Create a file and write data. The file in this example is secured, without signature and with a fail safe commit

       //create a secure file if not exists and open it for write.
       DeviceFileHandle =  sl_FsOpen(unsigned char *)DeviceFileName,
                            SL_FS_CREATE|SL_FS_OVERWRITE | SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE | SL_FS_CREATE_MAX_SIZE( MaxSize ),
                            &MasterToken);

       Offset = 0;
       //Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
       RetVal = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));

       RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

       // open the same file for read, using the Token we got from the creation procedure above
       DeviceFileHandle =  sl_FsOpen(unsigned char *)DeviceFileName,
                                        SL_FS_READ,
                                        &MasterToken);

       Offset = 0;
       RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));

       RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);

应该是FS打开操作后返回的各种标志位,通过这个可以确定是哪种。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top