• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

High speed Serial Port output

Hi,
 I am writing an application in which i need to output 3 bytes of data to the serial port 20 times a second. I tried to use the MSComm control but it seems to delay the output of the data (presumably because of buffering or something) and can not cope with the speed I require, so i get 'Out of stack space' errors. I am running my port and serial device at 9600baud so I would have thought this would have been fast enough as i should only require 480 baud (3 bytes * 8 bits per byte * 20 times a second = 480.) Is there any way to output the data faster without the delay/buffering using the MSComm control or any other alternative ways of serial port output? Sample code would be great too :)
Thanks,
Matt.
0
pyromatt
Asked:
pyromatt
  • 3
  • 2
1 Solution
 
GrahamSkanCommented:
There should be no problem running at that speed with the MSComm component

'Out of stack space' is usually caused by a recursive call gone out of control. I can't understand the connection with slow output.

Perhaps you should post your code
0
 
pyromattAuthor Commented:
Public Function SerOut(PortData As String)
 Do
  DoEvents 'Prevent 'Port already open' errors
 Loop Until frmMain.SerPort.PortOpen = False
 frmMain.SerPort.PortOpen = True
 frmMain.SerPort.Output = PortData
 frmMain.SerPort.PortOpen = False
End Function

PortData always contains 3 characters, and this fuction is used 20 times a second. The serial port however, only manages to output around 2 a second and so after a few seconds i get a stack space error.
0
 
GrahamSkanCommented:
Why don't you just leave the port open?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
pyromattAuthor Commented:
I thought you had to close the port to send the data? I always thought 'output' just buffers it and it isnt sent until you close it.
0
 
pyromattAuthor Commented:
Doh! Ive found the problem. I forgot to disable DTR and hence having to close the port everytime i need to send data (and hence the slowness)!
0
 
moduloCommented:
Closed, 200 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now