B
Bschriek
Guest
I have a .csv file with a lot of HEX values like 4E0,AC1,065,123,B00, 0A0,1C0,A04, 6F etc.
These numbers are actually measurement values from my datalogger.
But these values are now coded by an XOR function just before the values are saved to my .csv file.
I started with a simple test and coded all values by function"XOR" 0E0E. So actually 0E0E is my key.
The original measurement value is for example 4E0 and after the coding the result is E0E.
Now I need to decode my value of E0E to 4E0 again by use of the macro in Excel.
This can be done by the "XOR" 0E0E function again.
I already managed to write all .csv values to different rows in decimal format but these values are all still coded.
Who can help me to add a line to de-code my values?
Underneath my code:
Sub Import()
Application.Calculation = xlManual
Rows("9:1048576").Select ' Create an empty sheet
Selection.ClearContents
Sheets("Import").Select
Dim i
Dim sTemp As String
Dim CH1_voltage As Single
Dim CH1_current As Single
Dim CH2_voltage As Single
Dim CH2_current As Single
Dim vars() As String
Dim str As String
Dim j As Long
i = FreeFile
myFile = Application.GetOpenFilename()
Open myFile For Input As #1
N = 0
k = 10
bas = 1
'm = 0
Do While Not EOF(i)
Line Input #i, str
vars = Split(str, ",")
For j = LBound(vars) To UBound(vars) Step 4
'CH1 calculate voltage of Channel 1
t1 = Val("&h" & vars(j)) 'reads Hex and converts to Decimal raw value
ActiveCell.Offset(N, 0) = t1 'writes Decimal raw value to cell A10 but still coded!
' t1 = coded value XOR 0E0E or something like that.......................
' ActiveCell.Offset(N, 1) = t1 Here I like to see the decoded decimal value......
ActiveCell.Offset(N, 2) = (N) 'writes mSeconds
N = N + 1
Next j
Loop
Close #i
Calculate
End Sub
Continue reading...
These numbers are actually measurement values from my datalogger.
But these values are now coded by an XOR function just before the values are saved to my .csv file.
I started with a simple test and coded all values by function"XOR" 0E0E. So actually 0E0E is my key.
The original measurement value is for example 4E0 and after the coding the result is E0E.
Now I need to decode my value of E0E to 4E0 again by use of the macro in Excel.
This can be done by the "XOR" 0E0E function again.
I already managed to write all .csv values to different rows in decimal format but these values are all still coded.
Who can help me to add a line to de-code my values?
Underneath my code:
Sub Import()
Application.Calculation = xlManual
Rows("9:1048576").Select ' Create an empty sheet
Selection.ClearContents
Sheets("Import").Select
Dim i
Dim sTemp As String
Dim CH1_voltage As Single
Dim CH1_current As Single
Dim CH2_voltage As Single
Dim CH2_current As Single
Dim vars() As String
Dim str As String
Dim j As Long
i = FreeFile
myFile = Application.GetOpenFilename()
Open myFile For Input As #1
N = 0
k = 10
bas = 1
'm = 0
Do While Not EOF(i)
Line Input #i, str
vars = Split(str, ",")
For j = LBound(vars) To UBound(vars) Step 4
'CH1 calculate voltage of Channel 1
t1 = Val("&h" & vars(j)) 'reads Hex and converts to Decimal raw value
ActiveCell.Offset(N, 0) = t1 'writes Decimal raw value to cell A10 but still coded!
' t1 = coded value XOR 0E0E or something like that.......................
' ActiveCell.Offset(N, 1) = t1 Here I like to see the decoded decimal value......
ActiveCell.Offset(N, 2) = (N) 'writes mSeconds
N = N + 1
Next j
Loop
Close #i
Calculate
End Sub
Continue reading...