Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2016, 10:27:42 10:27


Login with username, password and session length


Pages: [1]
Print
Author Topic: Dude with Mmc_Fat_Library mikroC  (Read 1832 times)
0 Members and 1 Guest are viewing this topic.
juliozv
Junior Member
**
Offline Offline

Posts: 51

Thank You
-Given: 21
-Receive: 97



« on: May 21, 2013, 03:30:27 03:30 »

Hi,

I make a datalogger project, I use sensors like temperature, humidity and RTC, but I need to add the SD Card for keep the information. when I read the Mmc_Fat library of mikroC PRO but I don't understand well the next routine:

Mmc_Fat_Assing( filename , file_cre_attr)

* mikroC say
  file_cre_attr: file creation and attributs flags. Each bit corresponds to the appropriate file attribut:

Bit   Mask     Description

0   0x01     Read Only
1   0x02     Hidden
2   0x04     System
3   0x08     Volume Label
4   0x10      Subdirectory
5   0x20     Archive
6   0x40     Device (internal use only, never found on disk)
7   0x80     File creation flag. If file does not exist and this flag is set, a new file with specified name will be created.

in the part the "file_cre_attr" how is the configuraion of bits? in the example of mikroE has 0xA0 but I don't understand where this value.

thanks for your time..
Logged
bigtoy
Active Member
***
Offline Offline

Posts: 151

Thank You
-Given: 127
-Receive: 197


« Reply #1 on: May 21, 2013, 05:45:39 05:45 »

Hex 0xA0 is Binary 10100000, so bits 7 and 5 are set. In other words, "create a new file if the specified file name doesn't already exist", and "set the archive bit".  The remaining bits are all clear, so it's not a read-only file, not hidden, not a system file, not a volume label, not a subdirectory, and not a device.
Logged
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #2 on: May 21, 2013, 05:59:01 05:59 »

Hi,

I have never used the mikroC, but I guess you can OR the flags to assign multiple attributes to file.
e.g. 0x01 | 0x02 -> 0x03 -> Read Only + Hidden
      0x80 | 0x10 | 0x04 -> 0x94 -> Create file if doesn't exist, Make it(existing or new) System Subdirectory.

Of course, some of the combinations may be invalid.

It seems mikroC library is FAT16 implementation, you can get lots of info about it on net.

Hope this helps,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
pablo2048
Active Member
***
Offline Offline

Posts: 103

Thank You
-Given: 96
-Receive: 82


« Reply #3 on: May 21, 2013, 07:33:29 07:33 »

Just look into elm-chan fatfs module (http://elm-chan.org/fsw/ff/00index_e.html) - i suggest to define attributes in this way:
Code:
#define ATTR_READONLY (0x01)
#define ATTR_HIDDEN (0x02)
...
so You can write
Code:
Mmc_Fat_Assing(filename, ATTR_READONLY | ATTR_HIDDEN...)
Logged
juliozv
Junior Member
**
Offline Offline

Posts: 51

Thank You
-Given: 21
-Receive: 97



« Reply #4 on: May 21, 2013, 02:16:34 14:16 »

 Grin, yes it's a OR function:

In this case file_cre_attr = 0xA0, means Archive and File creation flag,
because, 0xA0 = 0x20 + 0x80 (0x20 -> Archive, 0x80 -> File creation flag).

Just look into elm-chan fatfs module (http://elm-chan.org/fsw/ff/00index_e.html) - i suggest to define attributes in this way:
Code:
#define ATTR_READONLY (0x01)
#define ATTR_HIDDEN (0x02)
...
so You can write
Code:
Mmc_Fat_Assing(filename, ATTR_READONLY | ATTR_HIDDEN...)

it's a good generic FAT file system module and similar of mikroC.

 Wink
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC