Forum Index > comm64 - input handling

By: David Posted on: Apr 21 2016 at 06:45:49 AM
Hi All,

This is my situation if I using laptop with RS232 to USB adapter to get signal from devices the signal will be (each line one input)

A12345DDD
A12345DDD
A12345DDD
A12345DDD

However when I PC with Com Port and following the data will receive from the program

A12345DDD
A123
45DDDA12
345DDD
A1
A12345DDDA12345DDD
A12345
DDD

Any solution or idea to make sure the "input" is receive the complete data and break one by one as above?

Following is my parameter setting on comm64

Comm1.CommPort = 1
Comm1.Settings = "2400,N,8,1"
Comm1.Handshaking = 0

Comm1.OutBufferSize = 1024
Comm1.sThreshold = 1
Comm1.InBufferSize = 4096
Comm1.rThreshold = 1
Comm1.InputLen = 0

Thank You!

By: Guest Posted on: Apr 25 2016 at 07:36:14 PM
The problem is that you, as a human, knows that the data is in distinct packets like
A12345DDDD
A12345DDDD
etc, etc.

But, in fact, it's just a continuous stream of data lik.
A12345DDDDA12345DDDDA12345DDDD

and theres no way that windows, or the serial port, can know where one packet ends and the other starts.

I guess there's a slight time gap between packets and the laptop, conincidentally, is grabbing the data between packets. But, as i said, that is more by coincidence than by design so you have to assume the data will come in irregular packets.

The correct way to do it to have a routine that simply reads data from the port and appends it into a local buffer. Then have another routine that is parsing the buffer looking for complete packets.

On the other hand, are the data packets seperated by anything such as a carriage return or line feed?. If they are then you could buffer the data locally until that character is received.

 

Reply - add comment to this topic
You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected
  Topic:- comm64 - input handling

Your Name


 


Forum scripts and databases - Copyright (c) 2009 - 2012 AxCoL.com