PDA

View Full Version : VB6 mbus commands?



welshwizard
06-11-2002, 10:19 PM
I found these @ http://www.vbforums.com/ (i assume i can say that as it is not a competing gsm/nokia forum).


need to output to com port
after reading loads of pages about how to use mscomm from here, i see it is really needed what you are outputting to etc to get real help
basically i need to output:
1F 00 10 40 00 04 00 01 6E 01 34 11 b7
followed by:
1F 00 10 7F 05
to com1 which is connected by m bus data cable to a Nokia phone. the phone will then return some data which i want displayed in a text box.
so far i managed to write:


code:--------------------------------------------------------------------------------Private Sub Command1_Click()
MSComm1.PortOpen = True
MSComm1.Output = "1F 00 10 40 00 04 00 01 6E 01 34 11 b7"
For i = 1 To 1000
Next i
MSComm1.Output = "1F 00 10 7F 05"
For i = 1 To 1000
Next i
Text1.Text = (MSComm1.Input)
End Sub

Private Sub MSComm1_OnComm()
MSComm1.Settings = "9600,o,8,1"
MSComm1.RTSEnable = True
MSComm1.DTREnable = False
MSComm1.PortOpen = False
End Sub--------------------------------------------------------------------------------


which does output (tested with portmon) but i get no input
also some source to do the same kind of thing (but outputting different m bus commands) i have is:

code:--------------------------------------------------------------------------------MSComm1.Settings = "9600,o,8,1"
MSComm1.RTSEnable = True
MSComm1.DTREnable = False
MSComm1.PortOpen = True
'hier is het test mode
thex ("1F 00 10 40 00 04 00 01 64 02 31 1D")
pause (100)
thex ("1F 00 10 7F 02")
MSComm1.PortOpen = False
MSComm1.PortOpen = True
thex ("1F 00 10 40 00 04 00 01 64 02 31 1D")
pause (100)
thex ("1F 00 10 7F 02")
MSComm1.PortOpen = False
'version bilgisi
MSComm1.PortOpen = True
buffer2$ = ""
thex ("1F 00 10 D1 00 05 00 01 00 03 00 32 EB")
pause (100)
thex ("1F 00 10 7F 03")
pause (100)
buffer2$ = ""
Do
DoEvents
buffer2$ = buffer2$ & MSComm1.Input
temp = Len(buffer2$)
If temp < 54 Then temp = 54
If temp = 54 Then GoTo erro
Loop While temp < 54

j = 1
For i = 1 To temp
arrayhex(j) = Mid(buffer2$, i, 1)
temp_ = arrayhex(j)
arraynum(j) = Asc(arrayhex(j))
j = j + 1
Next i
For i = 1 To temp
leitura1 = leitura1 + arrayhex(i)
Next i
geral = Mid(leitura1, 30, 31)
Text1 = geral
versao = Mid(leitura1, 30, 7)
Text2 = versao
tipo = Mid(leitura1, 47, 5)
Text3 = tipo
MSComm1.PortOpen = False
pause (100)
MSComm1.PortOpen = True
'Imei vragen
thex ("1F 00 10 40 00 03 00 01 66 33 18")
pause (100)
thex ("1F 00 10 7F 04")
pause (100)
buffer2$ = ""
Do
DoEvents
buffer2$ = buffer2$ & MSComm1.Input
temp = Len(buffer2$)
Loop While temp < 45
j = 1
For i = 1 To temp
arrayhex(j) = Mid(buffer2$, i, 1)
arraynum(j) = Asc(arrayhex(j))
j = j + 1
Next i
For i = 1 To temp
leitura2 = leitura2 + arrayhex(i)
Next i
imei = Mid(leitura2, 28, 6) + "-" + Mid(leitura2, 34, 2) + "-" +
Mid(leitura2, 37, 6) + "-" + Mid(leitura2, 42, 1)
Text4 = imei
MSComm1.PortOpen = False
pause (400)
MSComm1.PortOpen = True

'security code lezen
thex ("1F 00 10 40 00 04 00 01 6E 01 34 11 b7")
encrypt:
pause (100)
thex ("1F 00 10 7F 05")
pause (100)
Do
DoEvents
buffer2$ = ""
buffer2$ = buffer2$ & MSComm1.Input
temp = Len(buffer2$)
Loop While temp < 1
j = 1
For i = 1 To temp
arrayhex(j) = Mid(buffer2$, i, 1)
temp_ = arrayhex(j)
arraynum(j) = Asc(arrayhex(j))
j = j + 1
Next i
For i = 1 To temp
leitura3 = leitura3 + arrayhex(i)
Next i

lockcode = Mid(leitura3, 31, 5)
Text5 = lockcode
MSComm1.PortOpen = False
pause (300)
MSComm1.PortOpen = True
'level lezen (security l1.l2.l3.l4)

thex ("1F 00 10 40 00 04 00 01 8A 00 13 d3")
pause (100)
thex ("1F 00 10 7F 07")
buffer2$ = ""

buffer2$ = ""
Do
DoEvents
buffer2$ = buffer2$ & MSComm1.Input
temp = Len(buffer2$)
Loop While temp < 1
j = 1
For i = 1 To temp
arrayhex(j) = Mid(buffer2$, i, 1)
temp_ = arrayhex(j)
arraynum(j) = Asc(arrayhex(j))
j = j + 1
Next i
For i = 1 To temp
teste1 = Hex(arraynum(i))
If teste1 = "0" Then teste1 = "0" + teste1
If teste1 = "1" Then teste1 = "0" + teste1
If teste1 = "2" Then teste1 = "0" + teste1
If teste1 = "3" Then teste1 = "0" + teste1
If teste1 = "4" Then teste1 = "0" + teste1
If teste1 = "5" Then teste1 = "0" + teste1
If teste1 = "6" Then teste1 = "0" + teste1
If teste1 = "7" Then teste1 = "0" + teste1
If teste1 = "8" Then teste1 = "0" + teste1
If teste1 = "9" Then teste1 = "0" + teste1
If teste1 = "A" Then teste1 = "0" + teste1
If teste1 = "B" Then teste1 = "0" + teste1
If teste1 = "C" Then teste1 = "0" + teste1
If teste1 = "D" Then teste1 = "0" + teste1
If teste1 = "E" Then teste1 = "0" + teste1
If teste1 = "F" Then teste1 = "0" + teste1
leitura4 = leitura4 + teste1
Next i

locks = Mid(leitura4, 61, 2)
locks = Val("&h" + locks)
lockss = dec2bin(locks)

If lockss = "0" Then lockss = "0000"
If lockss = "1" Then lockss = "0001"
If lockss = "10" Then lockss = "0010"
If lockss = "11" Then lockss = "0011"
If lockss = "100" Then lockss = "0100"
If lockss = "101" Then lockss = "0101"
If lockss = "110" Then lockss = "0110"
If lockss = "111" Then lockss = "0111"
za = Len(lockss)

lock1 = Mid(lockss, za, 1)
lock2 = Mid(lockss, za - 1, 1)
lock3 = Mid(lockss, za - 2, 1)
lock4 = Mid(lockss, za - 3, 1)



If lock1 = 1 Then lock11 = "close"
If lock1 = 0 Then lock11 = "Open"
If lock2 = 1 Then lock22 = "close"
If lock2 = 0 Then lock22 = "Open"
If lock3 = 1 Then lock33 = "close"
If lock3 = 0 Then lock33 = "Open"
If lock4 = 1 Then lock44 = "close"
If lock4 = 0 Then lock44 = "Open"

Text6.SelText = "Lock 1 ...................................... " +
lock11 &
vbCrLf
pause (200)
Text6.SelText = "Lock 2 ...................................... " +
lock22 &
vbCrLf
pause (200)
Text6.SelText = "Lock 3 ...................................... " +
lock33 &
vbCrLf
pause (200)
Text6.SelText = "Lock 4 ...................................... " +
lock44 &
vbCrLf
MSComm1.PortOpen = False
pause (300)
MSComm1.PortOpen = True
' reset phone
thex ("1F 00 10 40 00 04 00 01 64 03 42 6F")
pause (100)
thex ("1F 00 10 7F 1C")
pause (100)

MSComm1.PortOpen = False--------------------------------------------------------------------------------

but i dont know what thex and pause are for plus some of the stuff makes no sense to me as i only been learning for a few days i put a loop as pause but dont know if thats correct.
any help would be nice

sam22
07-11-2002, 07:57 AM
i found a similar source code just like yours,but w/out the locks.
:(
For the pause
---------------------------------------------
Sub pause(pas As Single)
start = Timer
Do Until Timer >= start + pas / 1000
DoEvents
Loop
End Sub
----------------------------------------------

for the thex. this procedure puts &H in the string and send to the port. because in vb hex values has &H in front.

Ex. thex ("1F 00 10 40 00 04 00 01 8A 00 13 d3")
output &H1F &H00 &H10 &H40 &H00 &H04 &H00 &H01 &H8A
&H00 &H13 &Hd3



Sub thex(z As String)
Dim byt() As Byte
Dim buf1 As Variant
ReDim byt(Fix(Len(z) / 3))
j = 0
For i = 1 To Len(z) Step 3
y = "&H" + Mid(z, i, 2)
byt(j) = Val(y)
j = j + 1
Next i
buf1 = byt()
Form1.MSComm1.Output = buf1
End Sub
-------------------------------------------------

welshwizard
11-11-2002, 07:28 PM
any1 else got any nokia related source codes for VB6?

Joox
11-11-2002, 07:55 PM
yes, restart your dct3 phone and one which put a dct4 phone into test mode

Joox
12-11-2002, 12:50 PM
ok

Kilrah
12-11-2002, 01:00 PM
It has been some time now I'm looking for this...

@Joox:
Where did you get the commands that you send to the phone?
Could you send them to me please?
Are DTR disabled and RTS enabled to power the interface or is it required for communication? Because I've never been able to get an answer from my phone when sending commands with a teminal program (one I wrote in VB5, to send ASCII text and Hex values).

THX
Kilrah

Joox
12-11-2002, 01:18 PM
this sources are from www.gsm-software.net and i don't know anything abotu them. :D

Kilrah
12-11-2002, 01:27 PM
OK, thanks indeed :rolleyes:

Kilrah
12-11-2002, 01:30 PM
Must be interesting... you managed to get a login?
Did you dl everything?

Joox
12-11-2002, 01:45 PM
Hey look at my Sig. and you are asking if i have a login? :D

No, i didn't download everthing. just some sources about checksums. but there isnt very much which is downloadable on other sides. there is also a lot of crap sources.

Kilrah
12-11-2002, 01:54 PM
But as I see you haven't made any software which commuicates with the phone yet? only flash editing

So I'll continue searching.. Thanks! :)

sam22
12-11-2002, 05:26 PM
@ Kilrah

try to look at mygnokii documents. i think there are list of

mbus commands for nokia phones.

NokDoc
12-11-2002, 09:11 PM
Hi,

Here's the mbus commands from the gNokii package.

NokDoc

Kilrah
13-11-2002, 08:13 AM
Thanks. Will try withe these, and see if it works on a 3310...

Regards
Kilrah