Announcement

Collapse
No announcement yet.

serial port incomming ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • serial port incomming ?

    Hello.

    I need some help. I'm looking for a way to developpe
    a procedure beeing able to make me aware of incomming data
    on the comm port.
    I'm actualy using a timer which goes to see 1/10 seconds
    if there is some data to retreive from the buffer, but
    i'm looking how to do it whith a thread or Windows Event?

    Could someone send me an example of source code on how to do it?
    Thank 's.
    Dominique

  • #2
    In Windows, it is "usual" to use a thread to poll for incomming data.

    If you have PB/DLL 6.0 (which supports serial comms natively), be sure to investigate the \PBDLL60\SAMPLES\COMM\COMM.BAS example.

    Otherwise, search the BBS for "serial" and you should find some code, circa 1998 or early 1999 to perform serial comms with PB/DLL 5.0.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Dominique, what is your email address ? I can send you a code
      snippet with a working thread, SDK style.

      Regards, Jules

      ------------------
      Best regards
      Jules
      www.rpmarchildon.com

      Comment


      • #4
        Originally posted by Jules Marchildon:
        Dominique, what is your email address ? I can send you a code
        snippet with a working thread, SDK style.

        Regards, Jules
        Thank's for the Proposition, here is my EMails:
        [email protected] or:
        [email protected]

        ------------------
        Dominique

        Comment


        • #5
          Okay sent to mailto:[email protected][email protected]</A>

          Regards, Jules

          ------------------
          Best regards
          Jules
          www.rpmarchildon.com

          Comment


          • #6
            Thank's Jules for your help, i will have a try whith it
            and contact you then.
            But tryed already to compile your sources, failed !

            I'm surching for the reason, why does it fail during
            compilation of the commctrl.inc ? ?
            Whith the CreateWindow "SysAnimate32" fonction, it rings me
            of an Suntax error 516, that i can't found.
            My inc works well whith the others progs ! !


            Thank's for the Help.

            ------------------
            Dominique

            Comment


            • #7
              I compiled this using PBDLL50. I had to make some entries into
              the header files for the serial comm stuff to work. I will need
              to locate these again and send you the necessary structures and
              equates for the comm functions.

              I will compile it for you using PBDLL60 to make sure before I send it to you.

              Back to you soon...
              Best regards
              Jules
              www.rpmarchildon.com

              Comment


              • #8
                Okay, the solution...

                For the demo I sent, (same as source code forum posted)

                To compile in PBDLL60

                1. comment out the following, these are not needed for the demo.
                '$INCLUDE "COMMCTRL.INC"
                '$INCLUDE "COMDLG32"


                2. In your PBDLL60 win32api.inc file, make the following change.

                'comment out these structures supplied with PBDLL60 install.

                Code:
                                            '------------ *Modified* --------------------
                'TYPE COMSTAT
                '  fCtsHold AS LONG
                '  fDsrHold AS LONG
                '  fRlsdHold AS LONG
                '  fXoffHold AS LONG
                '  fXoffSent AS LONG
                '  fEof AS LONG
                '  fTxim AS LONG
                '  fReserved AS LONG
                '  cbInQue AS LONG
                '  cbOutQue AS LONG
                'END TYPE
                   
                'TYPE DCB
                '  DCBlength AS LONG
                '  BaudRate AS LONG
                '  fbits AS LONG       ' fBinary
                                       ' fParity
                                       ' fOutxCtsFlow
                                       ' fOutxDsrFlow
                                       ' fDtrControl
                                       ' fDsrSensitivity
                                       ' fTXContinueOnXoff
                                       ' fOutX
                                       ' fInX
                                       ' fErrorChar
                                       ' fNull
                                       ' fRtsControl
                                       ' fAbortOnError
                                       ' fDummy2
                
                '  wReserved AS INTEGER
                '  XonLim AS INTEGER
                '  XoffLim AS INTEGER
                '  ByteSize AS BYTE
                '  Parity AS BYTE
                '  StopBits AS BYTE
                '  XonChar AS BYTE
                '  XoffChar AS BYTE
                '  ErrorChar AS BYTE
                '  EofChar AS BYTE
                '  EvtChar AS BYTE
                '  wReserved2 AS INTEGER
                'END TYPE
                  
                 
                    and replace with
                 
                 
                TYPE COMSTAT                'Jules M. modified May 19, 1999
                  'fCtsHold AS LONG
                  'fDsrHold AS LONG
                  'fRlsdHold AS LONG
                  'fXoffHold AS LONG
                  'fXoffSent AS LONG
                  'fEof AS LONG
                  'fTxim AS LONG
                  fReserved AS LONG
                  cbInQue AS LONG
                  cbOutQue AS LONG
                END TYPE
                
                TYPE DCB                'Jules M. modified May 18, 1999
                  DCBlength AS LONG
                  BaudRate AS LONG
                  fBinary AS LONG
                  fParity AS LONG
                  fOutxCtsFlow AS LONG
                  fOutxDsrFlow AS LONG
                  fDtrControl AS LONG
                  fDsrSensitivity AS LONG
                  fTXContinueOnXoff AS LONG
                  fOutX AS LONG
                  fInX AS LONG
                  fErrorChar AS LONG
                  fNull AS LONG
                  fRtsControl AS LONG
                  fAbortOnError AS LONG
                  fDummy2 AS LONG
                  wReserved AS INTEGER
                  XonLim AS INTEGER
                  XoffLim AS INTEGER
                  ByteSize AS BYTE
                  Parity AS BYTE
                  StopBits AS BYTE
                  XonChar AS BYTE
                  XoffChar AS BYTE
                  ErrorChar AS BYTE
                  EofChar AS BYTE
                  EvtChar AS BYTE
                  wReserved2 AS INTEGER
                END TYPE				'---------- *End of Modified* -----------------
                We need to make sure any of the functions/subs declared that uses DCB and COMSTAT are
                the same size as the one I included with the demo. (DCBs and COMSTATs).

                It now compiles in PBDLL60. Sorry for the headache!

                Best regards, Jules
                Best regards
                Jules
                www.rpmarchildon.com

                Comment


                • #9
                  The latest versions of WIN32API.INC already have had those structures corrected for some time, Jules. http://www.powerbasic.com/files/pub/pbwin/win32api.zip


                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    Lance, thanks for pointing that out. The problem is that I did
                    not use the bit flags member "fbits". For some reason in the
                    past, I had problems using this member, so I used what was shown
                    in the book I used to get my demo running.

                    Snipped from your updated win32api.zip file...

                    Code:
                    TYPE DCB
                      DCBlength AS DWORD
                      BaudRate AS DWORD
                      fBits AS DWORD       ' fBinary
                                           ' fParity
                                           ' fOutxDtsFlow
                                           ' fOutxDsrFlow
                                           ' fDtrControl
                                           ' fDsrSensitivity
                                           ' fTXContinueOnXoff
                                           ' fOutX
                                           ' fInX
                                           ' fErrorChar
                                           ' fNull
                                           ' fRtsControl
                                           ' fAbortOnError
                                           ' fDummy2
                    
                      wReserved AS INTEGER
                      XonLim AS INTEGER
                      XoffLim AS INTEGER
                      ByteSize AS BYTE
                      Parity AS BYTE
                      StopBits AS BYTE
                      XonChar AS BYTE
                      XoffChar AS BYTE
                      ErrorChar AS BYTE
                      EofChar AS BYTE
                      EvtChar AS BYTE
                      wReserved2 AS INTEGER
                    END TYPE
                    Regards, Jules
                    Best regards
                    Jules
                    www.rpmarchildon.com

                    Comment


                    • #11
                      Hello Jules,

                      Thank's for the answer!
                      Just a litle probleme with your code:
                      In the "SUB ConfigComm()" procedure...
                      The test must be: "If GetCommState(hComm, BYREF pconfig) . . .
                      regarding to the fonction declaration !
                      With this changment, all works well.

                      What do you think about it ? Do i made another mistake ?

                      Nice to read you back .

                      ------------------
                      Dominique

                      Comment


                      • #12
                        I honestly don't know why you need to use the keyword byref. When
                        I compile, I don't get any errors. Maybe it is a time zone problem?

                        Regards, Jules

                        ------------------
                        Best regards
                        Jules
                        www.rpmarchildon.com

                        Comment

                        Working...
                        X