mauve928
asked on
mscomm1.input problem (pls need ur help, badly)
hi!
im developing an sms applciation using my nokia 6210 and dlr-3p cable, with vb (mscomm control)..
im in debugging stage of my program.. (dealine is sunday)
my problem, how come i cant get all the responses of mscomm1.input to be trasffered to strBuffer (as variant)..
-- here's the scenario--
dim strrep as variant
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input is used
MSComm1.InputLen = 0
mscomm1.rthreshold = 1
mscomm1. handshaking =0
mscomm1. rtsenable = ture
' Open the port
MSComm1.PortOpen = True
MSComm1.Output = "AT" & Chr$(13)
delay 5 ' a subfunction acts liek a timer; wait modemresponse
strBuffer = MSComm1.Input
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
delay 5
strBuffer = MSComm1.Input
MSComm1.Output = "AT+CNMI=1,1,0,0,0" & Chr$(13) ' new mesg indication
delay 3
strBuffer = MSComm1.Input
---------
Select Case MSComm1.CommEvent
dim strresponse as variant
' Event messages.
Case comEvReceive
strBuffer = MSComm1.Input
strresponse = strbuffer
inttemp = InStr(strResponse, "MT") ' new message
If InStr(strResponse, "+CMT") Or InStr(strBuffer, "+CMT") Then
strTemp = Mid(strResponse, inttemp, Len(strResponse))
sbrStatus.Panels(2).Text = "MESSAGE RECEIVE"
strRep = strResponse
ElseIf InStr(strResponse, Chr(34) & "MT" & Chr(34)) Or InStr(strBuffer, Chr(34) & "MT" & Chr(34)) Then
strTemp = strResponse
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strTemp
strRep = strResponse
Call OpenSMS
Beep
ElseIf InStr(strResponse, "+CGMR") Or InStr(strBuffer, "+CGMR") Or InStr(strtemp2, "+CGMR") Then
strtemp3 = strResponse
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse
Beep
Beep
ElseIf InStr(strResponse, "REC") Or InStr(strBuffer, "REC") Or InStr(strtemp2, "REC") Then
strtemp3 = strtemp2
Do Until InStr(strtemp2, "OK" & vbCrLf)
'Or InStr(buffer1, "OK" & vbCrLf) Or InStr(buffer1, "ERROR") Or InStr(strResponse, "ERROR")
DoEvents
strtemp2 = frmMain.MSComm1.Input & strtemp2
' buffer1 = frmMain.MSComm1.Input
Loop
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse & strtemp3
Beep
ElseIf InStr(strResponse, "READ") Or InStr(strBuffer, "READ") Or InStr(strtemp2, "READ") Then
strtemp3 = strtemp2
Do Until InStr(strtemp2, "OK" & vbCrLf)
DoEvents
strtemp2 = frmMain.MSComm1.Input
'& strtemp2
' buffer1 = frmMain.MSComm1.Input
Loop
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse
Beep
Beep
Call SplitArray
End Select
---------
Private Function OpenSMS()
strarray = Mid(strRep, 7, Len(strRep))
'inttemp = StrConv(Mid(strRep, 7, Len(strRep)), vbUnicode)
delay 1
MSComm1.Output = "AT+CMGR=" & Mid(strRep, 7, Len(strRep)) & Chr$(13)
delay 3
Debug.Print MSComm1.Input
strBuffer = MSComm1.Input
strtemp2 = strBuffer
Debug.Print strtemp2
Beep
End Function
------
Private Function SplitArray()
Dim strSplit(1 To 50) As Variant
Dim strSplits As Variant
Dim intSplits As Variant
Dim i As Integer
strSplits = strtemp2
'strSplits = strSplit
intSplits = InStr(strSplits, "+639") '8
strSplit(1) = Mid(strSplits, intSplits, 13) ' mobile number
intSplits = InStr(strSplits, Format(Now(), "yy/mm/dd"))
strSplit(2) = Mid(strSplits, intSplits, 8) ' date
intSplits = InStr(strSplits, Format("hh:mm:ss"))
strSplit(3) = Mid(strSplits, 22, 8) ' time
intSplits = InStr(strSplits, vbCrLf)
strSplit(3) = Mid(strSplits, intSplits, Len(strSplits)) ' time
intSplits = InStr(strSplits, "OK")
'strSplit(4) = Mid(strSplits, intSplits, 4) ' time
For i = 1 To 3 Step 1
frmReceiveMesg.Text2.Text = frmReceiveMesg.Text2.Text & Chr$(13) & strSplit(i)
Next i
End Function
------
when i recive a sms; on the frmReceiveMesg.Text2.Text = frmReceiveMesg.Text2.Text it usually contains only a part of the mesg..
when cursor is on debug.print.mscomm1.input
mscomm1.input =
+cmt: "rec unread", "+xxxxxxxxxxxx",,"yy/mm/dd ,hh:mm:ss+ xx"
mesg up to 160 char
<vbcrlf>
ok
<vbcrlf>
but it only displays part of the mesg.. like
"+xxxxxxxxxxxx",,"yy/mm/dd ,hh:mm:ss+ xx"
mesg up to 160 char
<vbcrlf>
ok
<vbcrlf>
or
"xxxxxx",,"yy/mm/dd,hh:mm: ss+xx"
mesg up to 160 char
---
is there a way i could go around and get the values form mscomm1.input..
i really am sorry, my question, this project is really driving me crazy..
please.. i really need all the help and suggstion you could give me..
thank u very much.. i appreciate eveything you coudl give me..
thank u.. again, im sorry, for a very unsual way of deliverign my question..
- mauve
im developing an sms applciation using my nokia 6210 and dlr-3p cable, with vb (mscomm control)..
im in debugging stage of my program.. (dealine is sunday)
my problem, how come i cant get all the responses of mscomm1.input to be trasffered to strBuffer (as variant)..
-- here's the scenario--
dim strrep as variant
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input is used
MSComm1.InputLen = 0
mscomm1.rthreshold = 1
mscomm1. handshaking =0
mscomm1. rtsenable = ture
' Open the port
MSComm1.PortOpen = True
MSComm1.Output = "AT" & Chr$(13)
delay 5 ' a subfunction acts liek a timer; wait modemresponse
strBuffer = MSComm1.Input
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
delay 5
strBuffer = MSComm1.Input
MSComm1.Output = "AT+CNMI=1,1,0,0,0" & Chr$(13) ' new mesg indication
delay 3
strBuffer = MSComm1.Input
---------
Select Case MSComm1.CommEvent
dim strresponse as variant
' Event messages.
Case comEvReceive
strBuffer = MSComm1.Input
strresponse = strbuffer
inttemp = InStr(strResponse, "MT") ' new message
If InStr(strResponse, "+CMT") Or InStr(strBuffer, "+CMT") Then
strTemp = Mid(strResponse, inttemp, Len(strResponse))
sbrStatus.Panels(2).Text = "MESSAGE RECEIVE"
strRep = strResponse
ElseIf InStr(strResponse, Chr(34) & "MT" & Chr(34)) Or InStr(strBuffer, Chr(34) & "MT" & Chr(34)) Then
strTemp = strResponse
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strTemp
strRep = strResponse
Call OpenSMS
Beep
ElseIf InStr(strResponse, "+CGMR") Or InStr(strBuffer, "+CGMR") Or InStr(strtemp2, "+CGMR") Then
strtemp3 = strResponse
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse
Beep
Beep
ElseIf InStr(strResponse, "REC") Or InStr(strBuffer, "REC") Or InStr(strtemp2, "REC") Then
strtemp3 = strtemp2
Do Until InStr(strtemp2, "OK" & vbCrLf)
'Or InStr(buffer1, "OK" & vbCrLf) Or InStr(buffer1, "ERROR") Or InStr(strResponse, "ERROR")
DoEvents
strtemp2 = frmMain.MSComm1.Input & strtemp2
' buffer1 = frmMain.MSComm1.Input
Loop
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse & strtemp3
Beep
ElseIf InStr(strResponse, "READ") Or InStr(strBuffer, "READ") Or InStr(strtemp2, "READ") Then
strtemp3 = strtemp2
Do Until InStr(strtemp2, "OK" & vbCrLf)
DoEvents
strtemp2 = frmMain.MSComm1.Input
'& strtemp2
' buffer1 = frmMain.MSComm1.Input
Loop
sbrStatus.Panels(2).Text = sbrStatus.Panels(2).Text & strtemp3
strRep = strResponse
Beep
Beep
Call SplitArray
End Select
---------
Private Function OpenSMS()
strarray = Mid(strRep, 7, Len(strRep))
'inttemp = StrConv(Mid(strRep, 7, Len(strRep)), vbUnicode)
delay 1
MSComm1.Output = "AT+CMGR=" & Mid(strRep, 7, Len(strRep)) & Chr$(13)
delay 3
Debug.Print MSComm1.Input
strBuffer = MSComm1.Input
strtemp2 = strBuffer
Debug.Print strtemp2
Beep
End Function
------
Private Function SplitArray()
Dim strSplit(1 To 50) As Variant
Dim strSplits As Variant
Dim intSplits As Variant
Dim i As Integer
strSplits = strtemp2
'strSplits = strSplit
intSplits = InStr(strSplits, "+639") '8
strSplit(1) = Mid(strSplits, intSplits, 13) ' mobile number
intSplits = InStr(strSplits, Format(Now(), "yy/mm/dd"))
strSplit(2) = Mid(strSplits, intSplits, 8) ' date
intSplits = InStr(strSplits, Format("hh:mm:ss"))
strSplit(3) = Mid(strSplits, 22, 8) ' time
intSplits = InStr(strSplits, vbCrLf)
strSplit(3) = Mid(strSplits, intSplits, Len(strSplits)) ' time
intSplits = InStr(strSplits, "OK")
'strSplit(4) = Mid(strSplits, intSplits, 4) ' time
For i = 1 To 3 Step 1
frmReceiveMesg.Text2.Text = frmReceiveMesg.Text2.Text & Chr$(13) & strSplit(i)
Next i
End Function
------
when i recive a sms; on the frmReceiveMesg.Text2.Text = frmReceiveMesg.Text2.Text it usually contains only a part of the mesg..
when cursor is on debug.print.mscomm1.input
mscomm1.input =
+cmt: "rec unread", "+xxxxxxxxxxxx",,"yy/mm/dd
mesg up to 160 char
<vbcrlf>
ok
<vbcrlf>
but it only displays part of the mesg.. like
"+xxxxxxxxxxxx",,"yy/mm/dd
mesg up to 160 char
<vbcrlf>
ok
<vbcrlf>
or
"xxxxxx",,"yy/mm/dd,hh:mm:
mesg up to 160 char
---
is there a way i could go around and get the values form mscomm1.input..
i really am sorry, my question, this project is really driving me crazy..
please.. i really need all the help and suggstion you could give me..
thank u very much.. i appreciate eveything you coudl give me..
thank u.. again, im sorry, for a very unsual way of deliverign my question..
- mauve
That comment about rtsenable having a typo for "true" could be the key:
"If you do set this [handshaking] value to either comRTS or comRTSXOnXOff, you need to set the RTSEnabled property to True. Otherwise, you will be able to connect and send, but not receive, data."
"If you do set this [handshaking] value to either comRTS or comRTSXOnXOff, you need to set the RTSEnabled property to True. Otherwise, you will be able to connect and send, but not receive, data."
ASKER
thank you, jimmack.. :)
i was able to change the handshaking property.. but still i wasnt able to get the whole modem response:
+cmgs: "mesg status" "+sendernum",,"yy/mm/dd,hh :mm:ss+xx
sms message (up to 160 chars)
(there is really a space here; vbcrlf)
OK
(there is really a space here; vbcrlf)
that is the value of mscomm1.input; however when i try to capture it to an variant variable, strbuffer; it seems it only gets/stores partial of the mesg..
example: strbuffer contains only this:
+sndernum",,yy/mm/dd,hh:mm :ss
also, most of the time, i get the diffuctly in capturing the contents of mscomm1.input; somehow, the moment when i try to store it to a variant varible, it is already empty.. (the contents seemed to hav flushed out).. (note: i put the transfering of the contents of mscomm1.input to str buffer on mscomm.Comevent = comEvRecieve or commevent = 2)
i dont know wat seems to be problem..
can you or anyone help me.. please.. i really really need to know how can i get the contents of mscomm1.input and then store it to a variable, where i can call a function to split the contents of that variable to the sender's number, date sent, time received, and the sms mesg.. then later store it to the databas (mscaccess), for processing of SQL statements.. this part of the program is very vital for my project..
thank you very much fro giving time to read and give comments, suggestions and help..
btw, yes jimmack; it is a typo.. sorry.. also for the typos for this comments..
thank you again.. :)
- mauve
i was able to change the handshaking property.. but still i wasnt able to get the whole modem response:
+cmgs: "mesg status" "+sendernum",,"yy/mm/dd,hh
sms message (up to 160 chars)
(there is really a space here; vbcrlf)
OK
(there is really a space here; vbcrlf)
that is the value of mscomm1.input; however when i try to capture it to an variant variable, strbuffer; it seems it only gets/stores partial of the mesg..
example: strbuffer contains only this:
+sndernum",,yy/mm/dd,hh:mm
also, most of the time, i get the diffuctly in capturing the contents of mscomm1.input; somehow, the moment when i try to store it to a variant varible, it is already empty.. (the contents seemed to hav flushed out).. (note: i put the transfering of the contents of mscomm1.input to str buffer on mscomm.Comevent = comEvRecieve or commevent = 2)
i dont know wat seems to be problem..
can you or anyone help me.. please.. i really really need to know how can i get the contents of mscomm1.input and then store it to a variable, where i can call a function to split the contents of that variable to the sender's number, date sent, time received, and the sms mesg.. then later store it to the databas (mscaccess), for processing of SQL statements.. this part of the program is very vital for my project..
thank you very much fro giving time to read and give comments, suggestions and help..
btw, yes jimmack; it is a typo.. sorry.. also for the typos for this comments..
thank you again.. :)
- mauve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Irrespective of how the interface is driven there is a general principle in driving these phones :-
The messages out are terminated with at least LF, best you use CR/LF
The messages in are terminated by CR/LF.
The phones DO NOT transmit complete lines but burst data back in bits. This means that, on the input side, you will not always have a complete line ready to be read in the buffer.
You must develop a routine to read a complete line back, preferably one character at a time, until the CR/LF sequence is found. You should also switch off Echo as this just wastes time. (This is why I always send CR/LF).
Some phones do transmit blank lines between the command and the response and between the response and the OK/ERROR message. You should be ready to ignore these.
The messages out are terminated with at least LF, best you use CR/LF
The messages in are terminated by CR/LF.
The phones DO NOT transmit complete lines but burst data back in bits. This means that, on the input side, you will not always have a complete line ready to be read in the buffer.
You must develop a routine to read a complete line back, preferably one character at a time, until the CR/LF sequence is found. You should also switch off Echo as this just wastes time. (This is why I always send CR/LF).
Some phones do transmit blank lines between the command and the response and between the response and the OK/ERROR message. You should be ready to ignore these.
ASKER
i apologize for replying for so long.. gotten busy with a lot of skul work and this thesis.. anyway, i did wat jimmack sugggested; and used a boolean flag variable so as to know if its receiveing an sms or other response to AT commands (at+cmgf, at+cnmi etc.. )
thank u, jimmack.. and i really apologize for taking long..
thank u gain.. ;)
thank u, jimmack.. and i really apologize for taking long..
thank u gain.. ;)
First, can you please clarify the exact problem. You imply that you get some data, but not the entire string. Is that correct? If so, is the partial data you receive correct?
(Bearing in mind my first sentence) Is this case sensitve? Whether it is or not, you should ensure that you're using the same case for all references, even if it is only for clarity:
' Tell the control to read entire buffer when Input is used
MSComm1.InputLen = 0
mscomm1.rthreshold = 1
mscomm1. handshaking =0
mscomm1. rtsenable = ture
should be:
' Tell the control to read entire buffer when Input is used
MSComm1.InputLen = 0
MSComm1.rthreshold = 1
MSComm1. handshaking =0
MSComm1. rtsenable = true
NOTE: That last line has a typo. You've put "ture" instead of "true"
Also, if RTS is enabled, shouldn't you be using this for the handshaking? (handshaking = 2)
That's a start. Let me know what happens with the changes and please don't forget to let me know what data you're getting (if any).