Private Sub AStream_NewData (Buffer() As Byte)
Dim RawInt As Int = Bit.ShiftLeft(Bit.And(Buffer(5), 0xFF), 24) + _
Bit.ShiftLeft(Bit.And(Buffer(4), 0xFF), 16) + _
Bit.ShiftLeft(Bit.And(Buffer(3), 0xFF), 8) + _
Bit.ShiftLeft(Bit.And(Buffer(2), 0xFF), 0)
Dim distance As Float = RawInt * 0.05/1000 'Direkt vom Laseranfang wird gemessen
Log("Distance: " & distance)
distance = distance + 0.105 'Es wird vom Gerätende gemessen
Log(NumberFormat(distance, 0, 3))
End Sub
Sub info
'Bosch GLM 50/100c Bluetooth PC-serial Measurement Log
'
'The following will put the laser into a mode where each measurement taken will be transmitted over bluetooth serial port profile.
'
'The device(s) send Min, Max, And current values immediately upon completing a measurement.
'To connect To your device, open the virtual COM port associated with your bluetooth driver (usually COM6). Your serial terminal must support HEX data, And allow To turn off CR/LF on transmit.
'
'Enable Logging:
'C0 55 02 01 00 1A
'
'Device responses will look like:
'
'[ Header ][ # ][ Err ][ Curr ][ Min ][ Max ][ Checksum ]
'
'Examples:
'C0 55 10 0A 08 6A 00 DC D7 C1 3F 4E D1 C1 3F C6 DC C1 3F 3C //1.514, 1.515, 1.515, 90 deg, back laser
'C0 55 10 0A 08 6B 00 A0 F8 BD 3F F7 E4 BD 3F C6 DC C1 3F 8A //1.484, 1.515, 1.484, 90 deg, back laser
'C0 55 10 0A 08 6C 00 13 F2 BD 3F F7 E4 BD 3F C6 DC C1 3F 84 //1.484, 1.515, 1.484, 90 deg, back laser
'This is the measurement data that is received
End Sub
Trying to figure *what* out?I've been trying to figure it out all day.
sounds like you need to set the measure-starting.-point in the device-settings.when I read out the laser via my app, I still have to add distance = distance + 0.105 because the laser only measures from the front end and not from the end of the device.
Yes, I did, so that it starts to measure at the end because you usually hold the device on the floor or on the wall, but the transmission via Bluetooth always only gives the value from the front of the device where the laser is located.sounds like you need to set the measure-starting.-point in the device-settings.
There is a setting for TOP, BASE and middle of the device i guess.
Check the documentation.
?I still have to add distance = distance + 0.105 because the laser only measures from the front end and not from the end of the device.
Option 1
SendCommand-Buffer = 00044A86000016 --> at exactly 1.824m
Option 2
SendCommand-Buffer = C0551006080208E09CE93F000000000000000006--> at exactly 1.825m
'SendCommand-Buffer = C0551006083C0815FBBF3F0000000000000000A0 = 150cm 1500 mm
Buffer = C0551006080208E09CE93F000000000000000006 = 1825 mm
'SendCommand-Buffer = C055100608420831080040000000000000000068 = 200cm 2000 mm
'SendCommand-Buffer = C055100608 3C0815FBBF3F 0000000000000000A0 = 150cm 1500 mm
Buffer = C055100608 0208E09CE93F 000000000000000006 = 1825 mm
'SendCommand-Buffer = C055100608 420831080040 000000000000000068 = 200cm 2000 mm
Option 2 the value is encoded as floating point
some code in B4J
Sub ExtractDistanceOption2(Buffer() As Byte) As Float
Dim FourBytes() As Byte = Array As Byte(Buffer(10), Buffer(9), Buffer(8), Buffer(7))
Dim bc As ByteConverter
Dim OneFloat() As Float = bc.FloatsFromBytes(FourBytes)
Return OneFloat(0)
End Sub
Dim SamplePackets(4) = Array As String( _
"C0551006083C0815FBBF3F0000000000000000A0", _
"C0551004086F08DA1BDC3F0000000000000000CC", _
"C0551006080208E09CE93F000000000000000006", _
"C055100608420831080040000000000000000068" _
)
For I = 0 To SamplePackets.Length - 1
Dim bc As ByteConverter
Dim Buffer() As Byte = bc.HexToBytes(SamplePackets(I))
Dim Distance As Float = ExtractDistanceOption2(Buffer)
Log(NumberFormat2(Distance, 1, 3, 3, False) & TAB & bc.HexFromBytes(Buffer))
Next
Waiting for debugger to connect...
Program started.
1.500 C0551006083C0815FBBF3F0000000000000000A0
1.720 C0551004086F08DA1BDC3F0000000000000000CC
1.825 C0551006080208E09CE93F000000000000000006
2.000 C055100608420831080040000000000000000068
in Option 1 the value is encoded as integer, and in Option 2 the value is encoded as floating point
Sub ExtractDistanceOption1(Buffer() As Byte) As Float
Dim FourBytes() As Byte = Array As Byte(Buffer(5), Buffer(4), Buffer(3), Buffer(2))
Dim bc As ByteConverter
Dim OneInt() As Int = bc.IntsFromBytes(FourBytes)
Return OneInt(0) * 0.00005 + 0.105
End Sub
Sub ExtractDistanceOption2(Buffer() As Byte) As Float
Dim FourBytes() As Byte = Array As Byte(Buffer(10), Buffer(9), Buffer(8), Buffer(7))
Dim bc As ByteConverter
Dim OneFloat() As Float = bc.FloatsFromBytes(FourBytes)
Return OneFloat(0)
End Sub
Dim SamplePackets(4) = Array As String( _
"C0551006083C0815FBBF3F0000000000000000A0", _
"C0551004086F08DA1BDC3F0000000000000000CC", _
"C0551006080208E09CE93F000000000000000006", _
"C055100608420831080040000000000000000068", _
"00044A86000016" _
)
For I = 0 To SamplePackets.Length - 1
Dim bc As ByteConverter
Dim Buffer() As Byte = bc.HexToBytes(SamplePackets(I))
If Buffer.Length > 10 Then 'distance at bytes 7 to 10
Dim Distance As Float = ExtractDistanceOption2(Buffer)
Else if Buffer.Length > 5 Then 'distance at bytes 2 to 5
Dim Distance As Float = ExtractDistanceOption1(Buffer)
Else
Dim Distance As Float = -1
End If
Log(NumberFormat2(Distance, 1, 3, 3, False) & TAB & bc.HexFromBytes(Buffer))
Next
Waiting for debugger to connect...
Program started.
1.500 C0551006083C0815FBBF3F0000000000000000A0
1.720 C0551004086F08DA1BDC3F0000000000000000CC
1.825 C0551006080208E09CE93F000000000000000006
2.000 C055100608420831080040000000000000000068
1.824 00044A86000016
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?