Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 29, 2024, 07:07:07 07:07


Login with username, password and session length


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

Posts: 67

Thank You
-Given: 34
-Receive: 166



« on: May 21, 2013, 02:30:27 02: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: 238

Thank You
-Given: 322
-Receive: 297


« Reply #1 on: May 21, 2013, 04:45:39 04: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
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #2 on: May 21, 2013, 04:59:01 04: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: 113

Thank You
-Given: 133
-Receive: 86


« Reply #3 on: May 21, 2013, 06:33:29 06: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: 67

Thank You
-Given: 34
-Receive: 166



« Reply #4 on: May 21, 2013, 01:16:34 13: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