Results 1 to 2 of 2

Thread: [RESOLVED] Modem data transfer between 2 computers

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    140

    Resolved [RESOLVED] Modem data transfer between 2 computers

    I tried to follow the steps mentioed in [URL="http://www.vbforums.com/showthread.php?t=574599"].. But I am not getting the message in Computer 2.
    Below is the code used to send the data
    vb Code:
    1. Imports system.IO.FileAccess
    2. Public Class Form1
    3.     Private Sub Form_Load()
    4.  
    5.     End Sub
    6.  
    7.     Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
    8.         Dim Number$, Temp$
    9.         Dim DialString$
    10.         Dim Status As String
    11.  
    12.         Text1.Text = "Test string from App1 "
    13.         Number$ = InputBox$("Enter phone number:", "Number$")
    14.         If Number$ = "" Then Exit Sub
    15.  
    16.         Temp$ = Status
    17.                Status = "Dialing - " + Number$
    18.         DialString$ = "ATDT" + Number$ + ";" + vbCr
    19.  
    20.         On Error Resume Next
    21.         If MSComm1.PortOpen = False Then
    22.             MSComm1.CommPort = 4
    23.             MSComm1.Settings = "9600,N,8,1"
    24.             MSComm1.PortOpen = True
    25.         End If
    26.  
    27.         MSComm1.Output = DialString$
    28.         Do
    29.             ' DoEvents()
    30.             Temp$ = Temp$ & MSComm1.Input
    31.         Loop Until InStr(Temp$, "OK" & vbCrLf)
    32.  
    33.         'Do Until MSComm1.CDHolding
    34.         MSComm1.Output = Text1.Text
    35.         'Loop
    36.         '  MSComm1.Output = Text1.Text
    37.     End Sub
    38.     Private Sub Form_Unload(ByVal Cancel As Integer)
    39.         MSComm1.PortOpen = False
    40.     End Sub
    41.  
    42.     Private Sub MSComm1_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MSComm1.OnComm
    43.         Dim EVMsg$
    44.         Dim ERMsg$
    45.         Select Case MSComm1.CommEvent
    46.             Case MSCommLib.OnCommConstants.comEvReceive
    47.                 Dim strReceived As Object
    48.                 strReceived = MSComm1.Input
    49.                 Text2.Text = Text2.Text & strReceived
    50.                 If MSComm1.PortOpen = True Then
    51.                     'MSComm1.Output = Text1.Text & vbCrLf
    52.                     Text1.Text = Text2.Text & vbCrLf
    53.                 End If
    54.  
    55.             Case MSCommLib.OnCommConstants.comEvSend
    56.             Case MSCommLib.OnCommConstants.comEvCTS
    57.             Case MSCommLib.OnCommConstants.comEvDSR
    58.             Case MSCommLib.OnCommConstants.comEvCD
    59.                 EVMsg$ = "Change in CD Detected"
    60.             Case MSCommLib.OnCommConstants.comEvRing
    61.                 EVMsg$ = "The Phone is Ringing"
    62.             Case MSCommLib.OnCommConstants.comEvEOF
    63.                 EVMsg$ = "End of File Detected"
    64.                 ' Error messages.
    65.             Case MSCommLib.CommEventConstants.comEventBreak
    66.                 ERMsg$ = "Break Received"
    67.             Case MSCommLib.CommEventConstants.comEventCDTO
    68.                 ERMsg$ = "Carrier Detect Timeout"
    69.             Case MSCommLib.CommEventConstants.comEventCTSTO
    70.                 ERMsg$ = "CTS Timeout"
    71.             Case MSCommLib.CommEventConstants.comEventDCB
    72.                 ERMsg$ = "Error retrieving DCB"
    73.             Case MSCommLib.CommEventConstants.comEventDSRTO
    74.                 ERMsg$ = "DSR Timeout"
    75.             Case MSCommLib.CommEventConstants.comEventFrame
    76.                 ERMsg$ = "Framing Error"
    77.             Case MSCommLib.CommEventConstants.comEventOverrun
    78.                 ERMsg$ = "Overrun Error"
    79.             Case MSCommLib.CommEventConstants.comEventRxOver
    80.                 ERMsg$ = "Receive Buffer Overflow"
    81.             Case MSCommLib.CommEventConstants.comEventRxParity
    82.                 ERMsg$ = "Parity Error"
    83.             Case MSCommLib.CommEventConstants.comEventTxFull
    84.                 ERMsg$ = "Transmit Buffer Full"
    85.             Case Else
    86.                 ERMsg$ = "Unknown error or event"
    87.         End Select
    88.  
    89.     End Sub
    90. End Class
    Below given is the code in second computer which is the receiving side

    vb Code:
    1. Public Class Form1
    2.     Dim CancelFlag
    3.  
    4.     Public mLoadOption As String ' Default or Recommended values
    5.     Public Connected As Boolean ' State of the CD line
    6.     Private RecFlag As Boolean ' Whether a file is to be received
    7.     Public Modem As Boolean 'Modem or serial cable
    8.     Private iReceiveFilenum As Short 'Freefile value for receiving files
    9.     Private iSendFilenum As Short 'Freefile value for sending files
    10.  
    11.  
    12.    
    13.  
    14.     Private Sub MSComm1_OnComm(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MSComm1.OnComm
    15.         Dim ErrMsg As Object
    16.         Dim InBuff As String
    17.  
    18.        
    19.  
    20.         Select Case MSComm1.CommEvent
    21.             ' Handle each event or error by placing
    22.             ' code below each case statement
    23.  
    24.             ' Errors
    25.             Case MSCommLib.CommEventConstants.comEventBreak ' A Break was received.
    26.                 ErrMsg = "Break"
    27.                 ' These next three timeout values are no longer detected in Win32
    28.             Case MSCommLib.CommEventConstants.comEventCDTO ' CD (RLSD) Timeout.
    29.             Case MSCommLib.CommEventConstants.comEventCTSTO ' CTS Timeout.
    30.             Case MSCommLib.CommEventConstants.comEventDSRTO ' DSR Timeout.
    31.  
    32.             Case MSCommLib.CommEventConstants.comEventFrame ' Framing Error
    33.  
    34.                 ErrMsg = "Framing"
    35.             Case MSCommLib.CommEventConstants.comEventOverrun ' Data Lost.
    36.  
    37.                 ErrMsg = "Overrun"
    38.             Case MSCommLib.CommEventConstants.comEventRxOver ' Receive buffer overflow.
    39.  
    40.                 ErrMsg = "OverFlow"
    41.             Case MSCommLib.CommEventConstants.comEventRxParity ' Parity Error.
    42.  
    43.                 ErrMsg = "Parity"
    44.             Case MSCommLib.CommEventConstants.comEventTxFull ' Transmit buffer full.
    45.  
    46.                 ErrMsg = "TX Full"
    47.             Case MSCommLib.CommEventConstants.comEventDCB ' Unexpected error retrieving DCB]
    48.  
    49.                 ErrMsg = "DBC"
    50.  
    51.                 ' Events
    52.             Case MSCommLib.OnCommConstants.comEvCD ' Change in the CD line.
    53.                 If MSComm1.CDHolding = True Then
    54.  
    55.                     Connected = True
    56.                 Else
    57.                   Connected = False
    58.                 End If
    59.  
    60.             Case MSCommLib.OnCommConstants.comEvCTS ' Change in the CTS line.
    61.             Case MSCommLib.OnCommConstants.comEvDSR ' Change in the DSR line.
    62.  
    63.                 ErrMsg = "comEvDSR"
    64.  
    65.             Case MSCommLib.OnCommConstants.comEvRing ' Change in the Ring Indicator.
    66.              
    67.  
    68.             Case MSCommLib.OnCommConstants.comEvReceive ' Received RThreshold # of chars.
    69.                 ' InBuff = MSComm1.Input
    70.                 'Call ScanCom(InBuff)
    71.                 InBuff = MSComm1.Input
    72.                 Call HandleInput(InBuff)
    73.             Case MSCommLib.OnCommConstants.comEvSend ' There are SThreshold number of
    74.                 ' characters in the transmit buffer.
    75.                 Do While MSComm1.OutBufferCount > 0
    76.                     System.Windows.Forms.Application.DoEvents()
    77.                 Loop
    78.  
    79.             Case MSCommLib.OnCommConstants.comEvEOF ' An EOF character was found in                        ' the input stream
    80.         End Select
    81.  
    82.     End Sub
    83.  
    84. Sub HandleInput(ByVal InBuff As String)
    85.         ' This is where you will process your input. This
    86.         ' includes trapping characters, parsing strings,
    87.         ' separating data fields, etc. For this case, you
    88.         ' are simply going to display the data in the TextBox.
    89.         Text1.SelectionStart = Len(Text1.Text)
    90.         Text1.Text = InBuff
    91.     End Sub
    92.  
    93.     Private Sub open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdopen.Click
    94.  
    95.         If MSComm1.PortOpen = False Then
    96.             MSComm1.CommPort = 4
    97.             MSComm1.Settings = "9600,N,8,1"
    98.             MSComm1.RThreshold = 1
    99.             MSComm1.InputLen = 0
    100.             MSComm1.PortOpen = True
    101.             MSComm1.Output = "ATV1Q0" & vbCrLf
    102.             MSComm1.Output = "ATSO=2" & vbCrLf
    103.             MSComm1.Output = "ATA"                      ' set modem to Auto Answer
    104.         Else
    105.             MsgBox("Port is already open" & MSComm1.CommPort & "Port", vbCritical, "Serial Data Logger")
    106.         End If
    107.     End Sub
    108. End Class
    What may be reason for not receiving the message

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Posts
    140

    Resolved Re: Modem data transfer between 2 computers

    The problem was after dialling the number, the mode is still in command mode. It has to be changed to data mode to send the data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width