Results 1 to 30 of 30

Thread: Problems with COM ports

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    17

    Problems with COM ports

    Brief Description
    I am trying to code a piece of software that will load a text file from a directory, then send that data out to a com port.
    The Problem
    I get an error on the machine that points to the BAUD rate being incorrect, yet I am confident that the BAUD is set correctly.

    Details
    I am sending the data via a Windows XP machine, running my software. It is connected to COM1. The PC is them directly connected via an RS232 cable to a Bosch CNC control (Model CC220).
    When I send my Data I get the following error;
    "Overflow Read Field" The error code it gives me is 2662.
    When I check the error codes, it tells me that Error 2662 is a "Loss of read-in data."
    It suggests that I check my BAUD rate, and it also points to problems with the interface or with the data iput device (the PC).
    I can rule out all but the BAUD rate, as I get the error wether I use my Laptop or the PC I have installed specifically for connecting to the CNC. I can also rule out interface errors, because we can communicate fine with the PC, using a DOS command to copy the file straight to the com port.

    The Code
    Code:
        Private Sub sendToLaser3()
            Try
                Using comPort As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(com)
                    If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
                        Dim fileReader As String
                        fileReader = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
                        comPort.DtrEnable = True
                        comPort.RtsEnable = True
                        comPort.Handshake = Ports.Handshake.None
                        comPort.BaudRate = 9600
                        comPort.Parity = Ports.Parity.Even
                        comPort.StopBits = Ports.StopBits.One
                        comPort.DataBits = 7
                        ' writes the fileBytes data to the comPort
                        comPort.WriteLine(fileReader)
                        comPort.Close()
                    End If
                End Using
            Catch ex As Exception
                MsgBox(com & " not found. Please try other com port(s)")
            End Try
            lblSending.Hide()
        End Sub
    I know this is quite specialised, but any help or ideas would be great,

    Fingers Crossed

    Dan
    Last edited by danweb; Jul 27th, 2007 at 04:30 AM. Reason: version vb.net

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