IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

pb lecture des données d'une carte SD


Sujet :

C

  1. #1
    Futur Membre du Club
    Inscrit en
    Octobre 2009
    Messages
    7
    Détails du profil
    Informations forums :
    Inscription : Octobre 2009
    Messages : 7
    Points : 7
    Points
    7
    Par défaut pb lecture des données d'une carte SD
    Bonjour à tous,

    J'essaie de communiquer avec une SD. Pour cela j'utilise la librairie de Microship MDD File System-SD Card. Je veux récupérer les propriétés de la carte SD (FAT, la taille de la SD,...). J'utilise pour cela la fonction FSGetDiskProperties.

    voici les explications concernant la fonction FSGetDiskProperties :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
     
    /*********************************************************************************
      Function:
        void FSGetDiskProperties(FS_DISK_PROPERTIES* properties)
      Summary:
        Allows user to get the disk properties (size of disk, free space, etc)
      Conditions:
        1) ALLOW_GET_DISK_PROPERTIES must be defined in FSconfig.h
        2) a FS_DISK_PROPERTIES object must be created before the function is called
        3) the new_request member of the FS_DISK_PROPERTIES object must be set before
            calling the function for the first time.  This will start a new search.
        4) this function should not be called while there is a file open.  Close all
            files before calling this function.
      Input:
        properties - a pointer to a FS_DISK_PROPERTIES object where the results should
          be stored.
      Return Values:
        This function returns void.  The properties_status of the previous call of this 
          function is located in the properties.status field.  This field has the 
          following possible values:
     
        FS_GET_PROPERTIES_NO_ERRORS - operation completed without error.  Results
          are in the properties object passed into the function.
        FS_GET_PROPERTIES_DISK_NOT_MOUNTED - there is no mounted disk.  Results in
          properties object is not valid
        FS_GET_PROPERTIES_CLUSTER_FAILURE - there was a failure trying to read a 
          cluster from the drive.  The results in the properties object is a partial
          result up until the point of the failure.
        FS_GET_PROPERTIES_STILL_WORKING - the search for free sectors is still in
          process.  Continue calling this function with the same properties pointer 
          until either the function completes or until the partial results meets the
          application needs.  The properties object contains the partial results of
          the search and can be used by the application.  
      Side Effects:
        Can cause errors if called when files are open.  Close all files before
        calling this function.
     
        Calling this function without setting the new_request member on the first
        call can result in undefined behavior and results.
     
        Calling this function after a result is returned other than
        FS_GET_PROPERTIES_STILL_WORKING can result in undefined behavior and results.
      Description:  
        This function returns the information about the mounted drive.  The results 
        member of the properties object passed into the function is populated with 
        the information about the drive.    
     
        Before starting a new request, the new_request member of the properties
        input parameter should be set to TRUE.  This will initiate a new search
        request.
     
        This function will return before the search is complete with partial results.
        All of the results except the free_clusters will be correct after the first
        call.  The free_clusters will contain the number of free clusters found up
        until that point, thus the free_clusters result will continue to grow until
        the entire drive is searched.  If an application only needs to know that a 
        certain number of bytes is available and doesn't need to know the total free 
        size, then this function can be called until the required free size is
        verified.  To continue a search, pass a pointer to the same FS_DISK_PROPERTIES
        object that was passed in to create the search.
     
        A new search request sould be made once this function has returned a value 
        other than FS_GET_PROPERTIES_STILL_WORKING.  Continuing a completed search
        can result in undefined behavior or results.
     
        Typical Usage:
        <code>
        FS_DISK_PROPERTIES disk_properties;
     
        disk_properties.new_request = TRUE;
     
        do
        {
            my_results = FSGetDiskProperties(&disk_properties);
        } while (disk_properties->properties_status == FS_GET_PROPERTIES_STILL_WORKING);
        </code>
     
        results.disk_format - contains the format of the drive.  Valid results are 
          FAT12(1), FAT16(2), or FAT32(3).
     
        results.sector_size - the sector size of the mounted drive.  Valid values are
          512, 1024, 2048, and 4096.
     
        results.sectors_per_cluster - the number sectors per cluster.
     
        results.total_clusters - the number of total clusters on the drive.  This 
          can be used to calculate the total disk size (total_clusters * 
          sectors_per_cluster * sector_size = total size of drive in bytes)
     
        results.free_clusters - the number of free (unallocated) clusters on the drive.
          This can be used to calculate the total free disk size (free_clusters * 
          sectors_per_cluster * sector_size = total size of drive in bytes)
     
      Remarks:
        PIC24F size estimates:
          Flash - 400 bytes (-Os setting)
     
        PIC24F speed estimates:
          Search takes approximately 7 seconds per Gigabyte of drive space.  Speed
            will vary based on the number of sectors per cluster and the sector size.
      *********************************************************************************/
    Voici mon main :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    FS_DISK_PROPERTIES disk_properties;
    FS_DISK_PROPERTIES *my_result;
    BYTE FAT;
    void F_init_hard(void);
     
    void main(void)
    {
     
    F_init_hard();
    FSInit();
     
     
        disk_properties.new_request = TRUE;
     
        do
        {
            my_result = FSGetDiskProperties(&disk_properties);
        } while (disk_properties.properties_status == FS_GET_PROPERTIES_STILL_WORKING);
     
    FAT = my_result.results.disk_format;
    L'erreur qui s'affiche est la suivante :

    C:\essai\SD card\sd\main1.c:78:Error [1131] type mismatch in assignment

    Je pense que mon erreur vient de la définition de mes variables et en particuliers de my_result.

    Si quelqu'un aurait une idée pour résoudre mon pb, je le remercie d'avance.

    A bientôt.

    Burby.

  2. #2
    Expert éminent sénior
    Avatar de diogene
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Juin 2005
    Messages
    5 761
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 761
    Points : 13 926
    Points
    13 926
    Par défaut
    D'après le prototype de la fonction FSGetDiskProperties() elle ne renvoie rien !

    void FSGetDiskProperties(FS_DISK_PROPERTIES* properties)
    ....
    On ne peux donc pas écrire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    my_result = FSGetDiskProperties(&disk_properties);
    mais simplement
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FSGetDiskProperties(&disk_properties);
    Publication : Concepts en C

    Mon avatar : Glenn Gould

    --------------------------------------------------------------------------
    Une réponse vous a été utile ? Remerciez son auteur en cliquant le pouce vert !

Discussions similaires

  1. Lecture et écriture des données dans une carte à puce
    Par junior222 dans le forum API standards et tierces
    Réponses: 7
    Dernier message: 30/11/2015, 15h57
  2. Représenter des données sur une carte
    Par Fnouch dans le forum R
    Réponses: 5
    Dernier message: 22/08/2013, 09h50
  3. Réponses: 0
    Dernier message: 09/03/2012, 23h41
  4. envoyer des données sur une carte son
    Par khalifa1 dans le forum DirectX
    Réponses: 1
    Dernier message: 26/10/2007, 17h29
  5. Réponses: 1
    Dernier message: 29/08/2007, 10h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo