this is like U see hex format
when i load file, I need to make this
"0012" first line of binary file ( here is hex ) are = 18 decimal and this is size of block need's to be sent at first
"DB3A" are checksum of that lenght
"0003" are device type
"0047" are number of block's in this binary file ( decimal = 71 block )
"00160000" are device ID1
"00160600" are device ID2
"00FFE3D" are size of binary file ( decimal = 1048125 bytes )
This all info is from first line of binary code ( I have put here hex for better understanding )
"0012DB3A000300470016000000160600000FFE3D"
Another block, size lenght and CRC
"436B" = 17259 ( binary lenght of second block )
"041A" = checksum
"8001" = not important
"7FF6" = decimal value 32758
"00000000" start address
Now using mscoom I need to send first ( 0012 hex = 18 decimal line of code )
send "DB3A000300470016000000160600000FFE3D" = 1 block size
wait for device to accept and store data
return from device = 06 ( this means that data are stored correctly )
What is is that you need help with? What code have you already written?
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
I havent write till now any code, coz I dont how !
I dont know how to load file and read from it what I have described in previous post ( read first bytes which will give me adresses, lenght of blocks, and lenght of entire blocks in file ).
I can send 1 mb file using mscomm control, that is not problem, but it will be not writed OK!
Here is small sample what info I need from that file when I load it to be able
send it correctly.
Lenght of block : 0x0012 (18)
Block CRC: 0xDB3A
Model Typ: 0x0003
Entire blocks in file: 0x0047 (71)
SistemID1: 0016.0000
SistemID2: 0016.0600
Entire File Lenght: 0x000FFE3D (1048125)
1.Load any binary file (example 10 kb)
2.Read first 15 bytes from file and put him in text box
3.Then skip (example) 40 bytes and select 10 bytes afther that then show them in text 2
4.create ini file with (text1 and text2) from this file I will use settings for programing device
From this sample I will be able to complete my project.
2.Read first 15 bytes from file and put him in text box
VB Code:
Text1.Text = Left$(strBuff, 15)
3.Then skip (example) 40 bytes and select 10 bytes afther that then show them in text 2
VB Code:
Text2.Text = Mid$(strBuff,56,10)
4.create ini file with (text1 and text2) from this file I will use settings for programing device
Search the site for Ini file handling. There are many threads showing various methods to use.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
OK, code working BUT!
When I load my binary file I can't see Info that I need.
I need convert it to hex but only to be able read info from that file.
When I see info, I need to send it as binary.
Private Sub Command1_Click()
cdlg.DialogTitle = "Select new ( BIN )..."
cdlg.Filter = "TST_UPD (*.bin)|*.bin|All Files (*.*)|*.*"
cdlg.InitDir = App.Path
cdlg.FileName = ""
cdlg.ShowOpen
If cdlg.FileName <> "" Then Count (cdlg.FileName)
End Sub
Function Count(strFilename)
Dim strBuff As String
Open strFilename For Binary As #1
strBuff = Space(LOF(1))
Get #1, , strBuff
Close #1
Text1.Text = Left$(strBuff, 30)
Text2.Text = Mid$(strBuff, 1024, 20)
End Function
This is OK, but when I load file i dont get in 1 txt box nothing and second is
?&/()=!"}§<>><§}{@´´˙`˛°˘^¨¸˝´˙`˛°
How to get HEX value in text boxes?
Here is small bin file...
Rename txt to bin
When U open file with HEX Editor U will see info what I need in my txt boxes.
'Get the byte you want to convert
strMyByte = Mid$(strBuff, 1, 18)
'then
ascMyByte = Asc(strMyByte) 'recover the ascii value
'and
strHEXMyByte = Hex$(ascMyByte) 'create the hex value
'if hex is a single byte (value 0 to 15), add a preceding "0"
If Len(strHEXMyByte) = 1 Then strHEXMyByte = "0" & strHEXMyByte
'display the results
Text1.Text = Str$(ascMyByte)
Text2.Text = strHEXMyByte
End Function
You have to convert ech btye in the buffer into 2 hex characters (using the code you posted in post #8), add it to the tex box, then go back and convert the next byte, etc., until the end of the buffer. Use a For ... Next loop, going from 1 to Len(strBuff), using Mid$(strBuff, <loop counter>, 1) to get each byte.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
but I have already make my soft work in another way.
I have split all blocks in separate files, rename it like this:
suk_HOT-BLOCK-1-17259-041A-1-000000.bin
suk_HOT-BLOCK-2-16430-800E-1-007FF6.bin
suk_HOT-BLOCK-3-17143-1873-1-00FFEC.bin etc.
So now I know number of block, filesize in bytes, checksum of block
and start address.
Now mscomm problems comes
Programming device...
B.R
VB Client/Server
Last edited by VB Client/Server; Jun 26th, 2006 at 04:50 PM.
There are many examples of using MSCOMM here, and the help in the help file has a usable example.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Now i cant get code to know when device is ready for programming
I need to receive some data from device to know that is connected
When I switch ON device I get "5A" as a response
Here is code:
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
With MSComm1
.CommPort = 1
.Handshaking = comNone
.RThreshold = 1
.RTSEnable = True
.DTREnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.InputMode = comInputModeBinary
.InputLen = 1
.PortOpen = True
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub Timer1_Timer()
On Error GoTo OpenError
Timer1.Interval = 50
'*************************************************
'*Do While MSComm1.......
'*DoEvents
'*Do Until MSComm1.Index = Chr$(&H5A)
'*If MSComm1.Input=chr$(&H5A) Then GoTo OK
'*Loop
' here I need code to determine when device is connected and ready
' when I power on device, I get "5A" character
' so "5A" means that device is powered ON and ready, programming can start
' and i need to remove any other char that might come when port is open
'*************************************************
'do whatever you need to tell the program that the device is on
End If
End If
End Sub
MSCom _OnComm fires when the control receives anything, so you don't need the timer.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana