Results 1 to 5 of 5

Thread: read output data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: read output data

    Assuming proper byte ordering and length of integer as 32 bits:
    Qt Code:
    1. unsigned char message[50]; // your message here
    2. int status;
    3. int statusFiscal;
    4. char text[41];
    5. memcpy(&status, message, 4);
    6. memcpy(&statusFiscal, message+5);
    7. memcpy(text, message+10, 40);
    8. text[40] = '\0';
    9. printf("status: %d\nfiscal: %d\ntext:%s\n", status, statusFiscal, text);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33
    Thanked 10 Times in 10 Posts

    Default Re: read output data

    I think your answer to my "problem" is correct, the thing is that i`m working with an emulator of a printer so that might be the problem of "extrange output". I`m receiving the warning: too many arguments for format while trying to execute:

    printf ("Respuesta: %s", buffer);
    this is something i should ignore?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: read output data

    The code seems correct. At least if you're using a regular compiler. What is the type of "buffer"? Is this your actual code? In your first post you have two %s marks in the line concerning "buffer".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    33
    Thanked 10 Times in 10 Posts

    Default Re: read output data

    Yes i had two separators, i was just trying to test what happened. The code posted is a method of a class. As private variables I have:
    Qt Code:
    1. int handler;
    2. char buffer[512];
    3. char comando[512];
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. why can't QProcess read all output?
    By Raul in forum Qt Programming
    Replies: 32
    Last Post: 15th June 2013, 13:17
  2. Read most recent output from QProcess's stdout
    By Lawand in forum Qt Programming
    Replies: 1
    Last Post: 8th September 2010, 23:29
  3. Help on QProcess - Output Read
    By augusbas in forum Qt Programming
    Replies: 5
    Last Post: 24th September 2009, 12:54
  4. can`t read a binary data!
    By blm in forum Qt Programming
    Replies: 8
    Last Post: 18th September 2008, 17:56
  5. How can I read binary data to QString?
    By zolookas in forum Newbie
    Replies: 2
    Last Post: 29th July 2008, 21:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.