I have some code I downloaded written in VB.NET that was written to send data throught the Serial Port (RS232). I have been experimenting with it and it does send data -- 2 characters at a time, no matter how many characters I try to send all at once in a string. So I assume that it can only send so many bits at a time and then clear the buffer before sending more.
That's what it appears to be -- correct me if I'm wrong.
With that assumption, I simply write to the port one character at a time looping through the string until I get to the end then close the port.
This works fine while I'm in debug mode with a break point at the Next statement, and pressing the F5 button once every time it goes through the loop.
But when I let it run by itself, it skips over characters and truncates the last part of the string.
It seems as though the computer just goes too fast for the port, so I have to somehow slow the loop down so that it will give the port a chance to handle the flow of data through it.
Is there any way to make the loop run slower?
Am I even on the right track? Is my assmption right about the number of bits that can be sent at one time?
I've tried different settings such as baud rate, but the default speed of 9,600 is the only one that will work.
Here's the code where I loop through the string and send it character by character:
That's what it appears to be -- correct me if I'm wrong.
With that assumption, I simply write to the port one character at a time looping through the string until I get to the end then close the port.
This works fine while I'm in debug mode with a break point at the Next statement, and pressing the F5 button once every time it goes through the loop.
But when I let it run by itself, it skips over characters and truncates the last part of the string.
It seems as though the computer just goes too fast for the port, so I have to somehow slow the loop down so that it will give the port a chance to handle the flow of data through it.
Is there any way to make the loop run slower?
Am I even on the right track? Is my assmption right about the number of bits that can be sent at one time?
I've tried different settings such as baud rate, but the default speed of 9,600 is the only one that will work.
Here's the code where I loop through the string and send it character by character:
Code:
(open comm port)
str = "this is a test" & Chr(9) & "Start Date" & Chr(9) & Chr(9) & _ "Location" & Chr(9) & "End Date"
lngth = str.Length - 1
For i = 0 To lngth
moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear Or _ Rs232.PurgeBuffers.RXClear)
ch = str.Substring(i, 1)
moRS232.Write(ch)
Next i
(close comm port)