Results 1 to 7 of 7

Thread: General Advice

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

    Default General Advice

    Hi guys, im facing what i think is going to be my biggest problem. I need to stablish a communication with a Fiscal Printer. For that i have the following files downloaded from the official website of the printer:
    1. winfis32.bas
    2. winfis32.dll
    3. Winfis.h
    4. winfis.lib


    To my surprise the header file included throws some extrange error when trying to compile: the sentence FAR PASCAL is not recognised. So i looked what was this and as I read is an old convention to especify parameters and size of pointers. (Precise and concise information here: http://stackoverflow.com/questions/2...-is-far-pascal).

    My question is: do i need to delete that part of the code?

    The drivers also include a way to communicate via OCX but as shown in the examples of the drivers documentation is recommended to use them when programming with Visual Basic. Should i change and work with OCX?

    here is the code of the header:
    Qt Code:
    1. #ifndef _WINFIS_H
    2. #define _WINFIS_H
    3.  
    4. #ifdef __cplusplus
    5. extern "C" {
    6. #endif
    7.  
    8. #define VERSION 427
    9.  
    10. #ifdef WIN32
    11. #define _export
    12. typedef void (*PFV)(int Reason, int Port);
    13. typedef void (__stdcall *PFVSTDCALL)(int Reason, int Port);
    14. #endif
    15.  
    16. int FAR PASCAL _export OpenComFiscal (int Com, int Mode);
    17.  
    18. int FAR PASCAL _export OpenTcpFiscal (char *HostName, int Socket, long TimeoutMilisecs, int Mode);
    19. #ifdef WIN32
    20. int FAR PASCAL _export ReOpenComFiscal (int Com);
    21. #endif
    22.  
    23. void FAR PASCAL _export CloseComFiscal (int Handler);
    24. int FAR PASCAL _export MandaPaqueteFiscal (int Handler, char *Buffer);
    25. int FAR PASCAL _export UltimaRespuesta (int Handler, char *Buffer);
    26. int FAR PASCAL _export UltimoStatus (int Handler, short *FiscalStatus,
    27. short *PrinterStatus);
    28. int FAR PASCAL _export VersionDLLFiscal (void);
    29. int FAR PASCAL _export InitFiscal (int Handler);
    30. void FAR PASCAL _export BusyWaitingMode (int Mode);
    31. int FAR PASCAL _export CambiarVelocidad(int Handler, long NewSpeed);
    32. void FAR PASCAL _export ProtocolMode(int Mode);
    33. long FAR PASCAL _export SearchPrn (int Handler);
    34.  
    35. int FAR PASCAL _export ObtenerNumeroDePaquetes (int Handler,
    36. int *Enviado, int *Recibido,
    37. int *CmdRecibido);
    38. #ifdef WIN32
    39. void FAR PASCAL _export SetKeepAliveHandler(PFV Handler);
    40. void FAR PASCAL _export SetKeepAliveHandlerStdCall(PFVSTDCALL Handler);
    41. void FAR PASCAL _export Abort(int Handler);
    42. #endif
    43.  
    44. int FAR PASCAL _export SetCmdRetries (int Retries);
    45. int FAR PASCAL _export SetSndRetries (int Retries);
    46. int FAR PASCAL _export SetRcvRetries (int Retries);
    47.  
    48. int FAR PASCAL _export SetModoEpson (int Modo);
    49.  
    50. #define SIZEANSWER 1024
    51.  
    52. #define MODE_ASCII 0
    53. #define MODE_ANSI 1
    54.  
    55. #define BUSYWAITING_OFF 0
    56. #define BUSYWAITING_ON 1
    57.  
    58. #define OLD_PROTOCOL 0
    59. #define NEW_PROTOCOL 1
    60.  
    61. #ifdef __cplusplus
    62. }
    63. #endif
    64.  
    65.  
    66. #endif // _WINFIS_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: General Advice

    Try:
    Qt Code:
    1. #include <windows.h>
    2. #include "Winfis.h"
    To copy to clipboard, switch view to plain text mode 
    in your source.

    You may find you have to use the OCX if you are using MingW and cannot link directly against the DLL.

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

    Default Re: General Advice

    OMG i just added that and functions ""perfectly"". I can`t really tell because I dont have the fiscal printer so when i do i ll keep you posted cause im going to need some help. Still im trying to learn and i wanna know more about the OCX... it`s like a cpp that connects the dll with the header? cause I read that the OCX contains functions that help me program, for example:

    if i only had the winfis.dll i would have to call like 10 functions to print a ticket, but with the OCX i just call print and it just know what to do with the .dll

    as far as i could understand lol

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: General Advice

    C code produces libraries with simple names and interfaces that can generally be accessed without great difficulty from any language. This appears to apply to your DLL based on the 'extern "C"' in the header.

    C++ code produces libraries with the class and method names mangled in a compiler specific fashion. The result is that libraries contain C++ classes etc. can only be directly used by code built with the same compiler. The DLL you have was built with a Microsoft compiler (educated guess) so, if it were a C++ library, you could not use it from a MingW program.

    A OCX file is a dynamic library that provides binary interfaces and mechanisms to access its "objects" in a compiler/language independent fashion. Look up "Common Object Model" (COM). You would access this code using ActiveQt but you need a reasonable grasp of COM to understand what is going on. OCX files were the easiest way to extend classic Visual Basic programs, which is why they recommend it.

  5. The following user says thank you to ChrisW67 for this useful post:

    KillGabio (2nd February 2012)

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

    Default Re: General Advice

    In the documentation of the program (I guess you dont talk Spanish thats why I`m not giving you the web site) says it`s for C language, that meaning I can use that DLL, right? I tried to use some functions but as the fiscal printer is not initialized cause I dont physically have it for now, I can only see that the method OpenComFiscal return a zero (0) indicating that the printer couldnt be initialized. That all said, I really hope it means i can interact with the fiscal controller...if not, well I`ll start to cry and learn some COM (actually im googling it right now).

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: General Advice

    If you can compile and link a program against this library then I think you will be fine.

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

    Default Re: General Advice

    I found it has an English version of the web site but in that mode it doesnt allow you to download the drivers of the printer...if you want to have a look:
    http://www.grupohasar.com/en/product...l/hasar-p-715f

    greetings tutor :P

Similar Threads

  1. General advice about scaling on QGraphicsView/QGraphicsScene
    By onurozcelik in forum Qt Programming
    Replies: 0
    Last Post: 24th May 2010, 08:14
  2. Customizable Analog clock general advice needed
    By been_1990 in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2009, 18:17
  3. General qt days..
    By Y-Less in forum Qt Programming
    Replies: 8
    Last Post: 10th April 2008, 21:41
  4. Few general problems
    By Salazaar in forum Newbie
    Replies: 9
    Last Post: 13th June 2007, 22:44
  5. General ListView Bug?
    By raphaelf in forum Qt Programming
    Replies: 14
    Last Post: 23rd February 2006, 13:54

Tags for this Thread

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.