Results 1 to 2 of 2

Thread: How long is the Buffer in Serial Communication?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    Sweden, Karlstad
    Posts
    1

    Lightbulb

    Hello friends,

    I'm using this to read RS232:
    Buffer = MSComm1.Input

    Is there a way read only to a curtain character? (crLF)

    I'm sending request with the MSComm1.Output and clearing the Buffer before every request but the Buffer are not receiving the same amount of data every time.

    Sometimes: 123.2 bar
    Sometimes: r 123
    Sometimes: ar 123.
    etc.

    I want to make sure that I capture the whole message in the buffer.

    Thanks for you help in advance!

    Marcus

  2. #2
    New Member
    Join Date
    Nov 2000
    Posts
    12
    I had the same issue and this is how I worked around it. I'm just taking the data 1 byte at a time until I hit the linefeed. I'm fairly new to vb so there is probably a better way to do it, but it works and it seems fast. I'm using vb5 and the vbterm sample helped me out quite a bit, it's a simple routine.

    MSComm1.InputLen = 1
    Do While MSComm1.InBufferCount > 0
    xbuffer = MSComm1.Input
    If Asc(StrConv(xbuffer, vbUnicode)) <> 10 Then
    If VarType(buffer) = 0 Then
    buffer = StrConv(xbuffer, vbUnicode)
    Else
    buffer = buffer & StrConv(xbuffer,vbUnicode)
    End If
    Else
    If VarType(buffer) <> 0 Then
    Debug.Print "Receive - " & buffer
    ShowData txtView, buffer
    buffer = ""
    End If
    End If
    Loop

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