Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Problem in getting data from serial port. Help!

i using the MSComm to communicate with the serial port. And i use the MSComm_ComEvReceive method to listen to the data receive from the serial port. The problem is how can i different the data that i have?

For example, if i receive a string "AT ABCVFDHow are u?".
"AT ABCVFD" is a command while "How are u" is the data. How to sort them out? Since the command and data always have the different amount of characters and received at different time. What should i do to sort them out? :( :(

Really need help here... thanks a lot for ur help. :)
[566 byte] By [speedss] at [2007-11-11 10:15:29]
# 1 Re: Problem in getting data from serial port. Help!
AT commands are terminated with a carriage return/line feed. Set the InputSize property to 1 and store characters in a buffer until you receive a carriage return.
Phil Weber at 2007-11-11 17:22:55 >
# 2 Re: Problem in getting data from serial port. Help!
by using the following code,
MSComm1.Input = strReceive

let we obtain strReceive = "AT 1234(CR)How are u(CR)"
where (CR) represent Carriage return

what code can i use to detect the position of the (CR) and obtain the command AT 1234" and data "How are u" seperately??

really had a hard time doing these... hope u can show some simple sample code. thank you very much.
speedss at 2007-11-11 17:23:56 >
# 3 Re: Problem in getting data from serial port. Help!
Dim Values() As String
Values = Split(strReceive, vbCr)
Phil Weber at 2007-11-11 17:24:51 >
# 4 Re: Problem in getting data from serial port. Help!
thanks you very much... i try to do on that. May i know is that most application involve serial communication use vbCrLf to differentiate the different type of data and command?
speedss at 2007-11-11 17:25:57 >