No announcement yet.

Comm stuff

  • Filter
  • Time
  • Show
Clear All
new posts

  • Comm stuff

    The messages where the Thread Create CommRingThread function was used seem to have been erased on the last upgrade of this BBS.

    I want to set comm as an event, so when the phone rings and event like %ES_RING occurs..

    Can someone refresh my memory? I'd appreciate it...

    Finally got time to sit down and write some code but I needed that sample


    mailto:[email protected][email protected]</A>
    Scott Turchin
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Hi Scott!
    Here's one way to do it (at least in Win2K & ME),
    #Compile Exe "C:\RING_ME.EXE"
    #Include ""
    Function CommWait(ByVal PortHandle As Long) As Long
      Dim EventMaskIn As Long             'Bit Map Of Event that occured
      Dim Reply       As Long
    'Tell Win32 What To Wait For:
      Call SetCommMask(PortHandle, %EV_RING)
    'Now Wait:
      Call WaitCommEvent(PortHandle, EventMaskIn, ByVal 0&)
      MsgBox "Ring Detected"
    End Function
    Function WinMain(ByVal hCurInstance   As Long, _
                     ByVal hPrevInstance  As Long, _
                     lpszCmdLine          As Asciiz Ptr, _
                     ByVal nCmdShow       As Long) Export As Long
      Dim hComm                           As Long
      Dim hCommPB                         As Long
      Dim hThread                         As Long
      Dim RingDetected                    As Long
    'Open a PB Comm Port:
      Comm Open "COM3" As #hCommPB
    'Get The Win32 Handle:
      hComm                               = FileAttr(hCommPB, 2)
    'Set The Comm Port Params:
      Comm Set #hCommPB, Baud             = 57600
      Comm Set #hCommPB, Byte             = 8
      Comm Set #hCommPB, Parity           = %False
      Comm Set #hCommPB, Stop             = 0
      Comm Set #hCommPB, TxBuffer         = 2048
      Comm Set #hCommPB, RxBuffer         = 4096
      Thread Create CommWait(hComm) To hThread
        Sleep 500
        Thread Status hThread To RingDetected
      Loop Until RingDetected = 0           'Thread's Dead
      MsgBox "Goodbye"
      Comm Close #hCommPB
    End Function
    Hope that helps?,

    [email protected]

    [This message has been edited by Wyman A Belts (edited September 04, 2000).]


    • #3
      Win 95 has a problem with RING this way!
      Read MSDN

      [email protected]