Results 1 to 2 of 2

Thread: Link with *.lib and send result value to Qt form?!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Link with *.lib and send result value to Qt form?!

    First of all Hi...

    This is my first post... I need some help!

    I have made some code for reading from parallel port. It work very good compiled with VSC++ like console application... It read LPT 1 sending results to screen and to file...

    When I tried to compile with qt, my first problem is that I need to call 3 *.lib for LPT communication...(or load dll library! how)

    Second problem is how to send result value to Qt form?!


    Qt Code:
    1. #include <stdafx.h>
    2. #include <stdio.h>
    3. #include <string.h>
    4. #include <stdlib.h>
    5. #include <math.h>
    6. #include <iostream>
    7. #include <windows.h>
    8.  
    9. #define E 8
    10. #define DIN 32
    11. #define CS 64
    12. #define CLK 128
    13. #define DOUT 128
    14. #define LPT 888
    15. #define vref 2.5
    16.  
    17.  
    18. short _stdcall Inp32(short PortAddress);
    19. void _stdcall Out32(short PortAddress, short data);
    20.  
    21.  
    22. int main()
    23. {
    24. int prs, lima, p, limas, ps;
    25. int ks, k, i, c, s;
    26. int CONF[8]= {142,206,158,222,174,238,190,254};
    27. double volt[20], voltr[4], temp[4], DATO;
    28.  
    29. FILE * f_one;
    30. f_one = fopen("a_m.txt", "w+");
    31.  
    32. for (s=0; s<=2; s++)
    33. {
    34. for (c=1; c<=8; c++)
    35. {
    36. for (i=7; i>-1; i--)
    37. {
    38. lima=pow(2.0,i);
    39. p=CONF[c]&lima;
    40. if (p==lima) {Out32(LPT,DIN+E);}
    41. else Out32(LPT,E);
    42. Out32(LPT,E+CLK);
    43. Out32(LPT,E);
    44. }
    45. DATO=0;
    46. for (i=11; i>-1; i--)
    47. {
    48. Out32(LPT,E+CLK);
    49. Out32(LPT,E);
    50. ps=Inp32(LPT+1)&DOUT;
    51. limas=pow(2.0,i);
    52. if (ps==0) {DATO=(DATO+limas);}
    53. }
    54.  
    55. Out32(LPT,E+CS);
    56. k=(c+8*s);
    57. if (k<=20)
    58. {volt[k] = DATO * (vref / 4095);
    59. printf (" %.2f", volt[k]); //print to screen
    60. fprintf (f_one,"%.2f ", volt[k]);} //print to file
    61. if (k>20)
    62. {ks=24-k;
    63. voltr[ks] = DATO * (vref / 4095);
    64. temp[ks]=voltr[ks]/10;
    65. printf (" %.1f", temp[ks]); //print to screen
    66. fprintf (f_one,"%.1f ", temp[ks]);} //print to file
    67.  
    68. Sleep(25);
    69. }
    70. }
    71. Sleep(25);
    72. printf ("\n");
    73. fprintf (f_one,"\n");
    74. fclose(f_one);
    75. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 19th August 2007 at 20:43. Reason: missing [code] tags

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.