My Objective is , Using the serial port cable i have connected the 2 systems. 1 system act as Server another one act as Modem.
Server have send the some standard comment to modem in every 500Millisec using the timer. Modem read the comment and send reply to one standard comment (Only 0 or 1.
Server split the comment and stored in labels (16 label). Then using Timer server have increase the value in all Labels (100Millisec).
Everything working fine on this. But Sometime Server was unable to read the full comment which was send from modem.
Kindly advice how to proceed further.
Dim Serial_Data As String
Glb_Serial_Data = Serial1.ReadAll()
Serial_Arary = Glb_Serial_Data.Split("|")
iMachine_Status(0) = Val(Serial_Arary(0))
iMachine_Status(1) = Val(Serial_Arary(1))
iMachine_Status(2) = Val(Serial_Arary(2))
iMachine_Status(3) = Val(Serial_Arary(3))
iMachine_Status(4) = Val(Serial_Arary(4))
iMachine_Status(5) = Val(Serial_Arary(5))
iMachine_Status(6) = Val(Serial_Arary(6))
iMachine_Status(7) = Val(Serial_Arary(7))
iMachine_Status(8) = Val(Serial_Arary(8))
iMachine_Status(9) = Val(Serial_Arary(9))
iMachine_Status(10) = Val(Serial_Arary(10))
iMachine_Status(11) = Val(Serial_Arary(11))
iMachine_Status(12) = Val(Serial_Arary(12))
iMachine_Status(13) = Val(Serial_Arary(13))
iMachine_Status(14) = Val(Serial_Arary(14))
iMachine_Status(15) = Val(Serial_Arary(15))
Timer 1 :
If(iMachine_Status(0) =1) Then
//Similar to all labels //
Dim s As String
s= “ST” + EndOfLine
Is there a delimiter, such as end-of-line, that tells you when you have received a complete response? DataAvailable will fire after some data has been received, but it has no way of knowing what constitutes a complete message. Therefore, you may not have a complete message (or you may have more than one message) when DataAvailable fires. It may take several DataAvailable events to get the complete message. Use LookAhead to see if you have a complete message before you process it.
Yes… Server didn’t receive complete message from Modem at some time…
Kindly advice how to fire the data available after getting the complete message
If you don’t have a complete message yet, then do nothing. Another DataAvailable event will fire when more of the message has been received. If you still don’t have a complete message, then do nothing and wait for yet another DataAvailable, etc.
“Is there a delimiter, such as end-of-line, that tells you when you have received a complete response?”
Could u please tell which delimiter i should use to find the complete message received or not…
That is completely dependent on the hardware you’re using. I could not begin to guess. Consult the manual for the hardware you are using. (Note however, that modems usually do use to terminate their messages, so that is a good guess.)
I didn’t use the hardware… Using RS232 cable i have connect the 2 Systems… In Both system i have use the different Xojo code for sending & receiving the comments.
Then what is your Xojo code? If you use WriteLine, then EndOfLine is the delimiter. If you use Write, then there is no delimiter, unless you are explicitly appending one to the message.
I have used as
Serial1.Write (A + EndOfLine)
A contains the Some comment.
Then EndOfLine is your delimiter. Look for that in the data you receive.
dim n as integer = instr(me.lookahead, EndOfLine)
if n <= 0 then return
dim message as string = me.read(n)
Thanks Dim… Its working fine now