Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Saving Screenshot from Rohde and Schwarz Spectrum Analyser to PC
Qt 6.11 is out! See what's new in the release blog

Saving Screenshot from Rohde and Schwarz Spectrum Analyser to PC

Scheduled Pinned Locked Moved Unsolved C++ Gurus
5 Posts 3 Posters 1.2k 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.
  • P Offline
    P Offline
    Pariposh
    wrote on last edited by
    #1

    Hey, I want to capture a screenshot on Rohde and Schwarz Spectrum Analyser via ethernet commands and then automatically retrieve that screenshot to my PC location via ethernet TCPIP but im not able to retrieve the screenshot back after taking the screenshot.
    Kindly Help me with this ,

    Currently im trying with the below code :

         //Send the command to capture a screenshot
                strcpy(buffer, ":DISPlay:DATA? PNG, COLor");
                if (send(sa_socket_desc, buffer, strlen(buffer), 0) < 0) {
                    perror("Send error");
                    exit(1);
                }
    
                // Receive the screenshot data
                fp = fopen("screenshot.png", "wb");
                if (fp == NULL) {
                    perror("File open error");
                    exit(1);
    
                    while ((bytes_read = recv(sa_socket_desc, buffer, BUFFER_SIZE, 0)) > 0) {
                        fwrite(buffer, 1, bytes_read, fp);
                    }
    
                    fclose(fp);
    
    JonBJ 1 Reply Last reply
    0
    • P Pariposh

      Hey, I want to capture a screenshot on Rohde and Schwarz Spectrum Analyser via ethernet commands and then automatically retrieve that screenshot to my PC location via ethernet TCPIP but im not able to retrieve the screenshot back after taking the screenshot.
      Kindly Help me with this ,

      Currently im trying with the below code :

           //Send the command to capture a screenshot
                  strcpy(buffer, ":DISPlay:DATA? PNG, COLor");
                  if (send(sa_socket_desc, buffer, strlen(buffer), 0) < 0) {
                      perror("Send error");
                      exit(1);
                  }
      
                  // Receive the screenshot data
                  fp = fopen("screenshot.png", "wb");
                  if (fp == NULL) {
                      perror("File open error");
                      exit(1);
      
                      while ((bytes_read = recv(sa_socket_desc, buffer, BUFFER_SIZE, 0)) > 0) {
                          fwrite(buffer, 1, bytes_read, fp);
                      }
      
                      fclose(fp);
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Pariposh
      Code above should work but has nothing to do with Qt. Since all it does is save every byte received to a file nobody can know what the issue in your case might be.

      EDIT
      Oh, hang on a minute, your code is not right! Look at when/where you have set your while loop to execute :)

      P 1 Reply Last reply
      0
      • JonBJ JonB

        @Pariposh
        Code above should work but has nothing to do with Qt. Since all it does is save every byte received to a file nobody can know what the issue in your case might be.

        EDIT
        Oh, hang on a minute, your code is not right! Look at when/where you have set your while loop to execute :)

        P Offline
        P Offline
        Pariposh
        wrote on last edited by
        #3

        @JonB i gaave some debug prints in the above code already and got to know that there is some issue in the while loop only , but im not getting how to resolve that issue.

        jsulmJ JonBJ 2 Replies Last reply
        0
        • P Pariposh

          @JonB i gaave some debug prints in the above code already and got to know that there is some issue in the while loop only , but im not getting how to resolve that issue.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Pariposh said in Saving Screenshot from Rohde and Schwarz Spectrum Analyser to PC:

          but im not getting how to resolve that issue

          What about telling us what that issue actually is?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Pariposh

            @JonB i gaave some debug prints in the above code already and got to know that there is some issue in the while loop only , but im not getting how to resolve that issue.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Pariposh
            Just look at your code:

             exit(1);
            
             while ((bytes_read = recv(sa_socket_desc, buffer, BUFFER_SIZE, 0)) > 0) {
            

            This cannot possibly be correct, can it?

            1 Reply Last reply
            1
            • SGaistS SGaist moved this topic from General and Desktop on

            • Login

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