Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. memory mapped file help
QtWS25 Last Chance

memory mapped file help

Scheduled Pinned Locked Moved General and Desktop
fileprocessmap
5 Posts 3 Posters 4.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ivanperino
    wrote on 18 Apr 2015, 00:39 last edited by
    #1

    I need some help regarding sharing data between two different applications made with Qt. Such data must reside on hard disk because I am not allowed to lose any information in case of energy failure.
    Is it possible to achieve this using a file mapped to memory?

    Anybody have an brief example or lineament?

    Thank you very much

    T 1 Reply Last reply 18 Apr 2015, 03:50
    0
    • I ivanperino
      18 Apr 2015, 00:39

      I need some help regarding sharing data between two different applications made with Qt. Such data must reside on hard disk because I am not allowed to lose any information in case of energy failure.
      Is it possible to achieve this using a file mapped to memory?

      Anybody have an brief example or lineament?

      Thank you very much

      T Offline
      T Offline
      TioRoy
      wrote on 18 Apr 2015, 03:50 last edited by
      #2

      @ivanperino

      You can use a QFile that inherits from QFileDevice

      Use the functions QFileDevice::map and unmap.

      I 1 Reply Last reply 18 Apr 2015, 04:37
      1
      • T TioRoy
        18 Apr 2015, 03:50

        @ivanperino

        You can use a QFile that inherits from QFileDevice

        Use the functions QFileDevice::map and unmap.

        I Offline
        I Offline
        ivanperino
        wrote on 18 Apr 2015, 04:37 last edited by
        #3

        @TioRoy
        Thanks for your advice. I have read about QFile and its heritance. But speciffically I need an answer a bit more detailed:

        Am I able to share information without loosing anything in case of power failure? Because this is my purpose.
        One app uses data in file and ocassionally write data to it using a human interface. In the other hand, another app read and write data to the same file through serial port.
        I cannot use pipe nor socket because information would become volatile.

        The second question is about a simple example if anybody has some.

        Thankyou anyway

        Sincerely

        Ivan

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on 18 Apr 2015, 06:33 last edited by
          #4

          Hi,

          a QFile is by default persistent so you can be sure to not loose information.
          BTW you have to synchronize the access to the file.

          Do you really need two application to do this work? In that case I suggest to

          1. The reader application reads data from serial port and sends them to the GUI using standard IPC

          2. The consumer store data on a file and use them

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          I 1 Reply Last reply 18 Apr 2015, 14:03
          0
          • M mcosta
            18 Apr 2015, 06:33

            Hi,

            a QFile is by default persistent so you can be sure to not loose information.
            BTW you have to synchronize the access to the file.

            Do you really need two application to do this work? In that case I suggest to

            1. The reader application reads data from serial port and sends them to the GUI using standard IPC

            2. The consumer store data on a file and use them

            I Offline
            I Offline
            ivanperino
            wrote on 18 Apr 2015, 14:03 last edited by
            #5

            I understand your advice. 1 app access the file and the other app communicate directly to the first app. However, I aimed to use a memory-mapped-file just because I read some articles where it said this is one of the best practice to communicate two process without lossing information. Is this correct?

            I am really interested in your advices, so I present my case:

            GUI <-> MainAPP <-> SPortAPP

            GUI can be anything made for anybody with the only requirement of implementing a protocol/API to communicate to MainAPP. (e.g. sockets)
            MainAPP is my application who implement mathematics, logic, etc and defines the behaviour of my system. It cannot lose any information so I thought I might save it on a file.
            SPortAPP is a propietary protocol implementation whereby external systems read/write information to the database of MainAPP . This app shouldn't interact directly to MainAPP
            So, Such information must be available to read and write by both MainAPP and SPortAPP.

            what is your opinion about it? Do you reccomend any other type of implementation?

            1 Reply Last reply
            0

            2/5

            18 Apr 2015, 03:50

            • Login

            • Login or register to search.
            2 out of 5
            • First post
              2/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved