I am working trying to better understand comports and the maximum data transmission rates. The results I am seeing are puzzling.
Using a FEZraptor, and simply tying the input to the output of two different comports using simple jumpers and a breakout module.
Running the latest prelease from GHI.
I measure the following using the debug statements, and a logic analyzer:
At 921600 baud, 24.13 frames per seconds, 43.66mS between end of frame and start of next frame, frame time = 750uS
At 115200 baud, 7.86 frames per second, frames broken in the 15 character blocks, 21 mS gap between blocks, 43mS gap between frame end and start
At 9600 baud, 1.42 frames per second, frames brokent into 2 character blocks, 21 ms gap between blocks, 43mS gap between frame end and start
For reference, a baudrate of 115200 should results in a maximum of (115200 / 10 / 63) = `82 frames / second
While I would not expect that due to overhead, I would not expect to get less than 10% of that. I also would not expect the frames to be fractured.
Any ideas would be appreciated.
Imports GT = Gadgeteer
Imports Gadgeteer.SocketInterfaces
Namespace SerialTest
Partial Public Class Program
Public baud As Integer = 9600 ' 115200 ' 921600
Dim starttime As DateTime
Private frames As Integer = 0
Public Sub ProgramStarted()
Debug.Print("Program Started")
Thread.Sleep(5000)
_rs232.Configure(baud, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired)
_rs2322.Configure(baud, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired)
Dim test As New Thread(AddressOf Test1)
test.Start()
End Sub
Dim teststring As String = "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz"
Private Sub Test1()
Debug.Print("Start test1 at " & baud & " baud")
Dim buffer() As Byte = New Byte(teststring.Length - 1) {}
_rs232.Port.Write(teststring) ' send from first comport to second via loopback
starttime = DateTime.Now
Do
If _rs2322.Port.BytesToRead >= teststring.Length Then
_rs2322.Port.Read(buffer, 0, _rs2322.Port.BytesToRead) ' reading from second comport
frames += 1
If frames Mod 10 = 0 Then displayrate()
_rs232.Port.Write(teststring) ' write from first comport
End If
Loop
End Sub
Private Sub displayrate()
Dim et As Double = (DateTime.Now - starttime).Ticks / TimeSpan.TicksPerSecond
Debug.Print(et.ToString("D") & " seconds or " & (frames / et).ToString("D"))
End Sub
End Class
End Namespace
@ Gus - this is in VB just for you